Changeset 477


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

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/resource.hh

    r474 r477  
    7373                resource() : m_id(0), m_handler( nullptr ) {}
    7474                bool is_valid() const { return m_id.valid() && m_handler != nullptr;  }
     75                resource_id id() const { return m_id; }
    7576                ~resource()
    7677                {
  • trunk/nv/engine/program_manager.hh

    r474 r477  
    2020{
    2121
    22         class program_manager : public resource_manager< program >
     22        class program_manager : public lua_resource_manager< program, false >
    2323        {
    2424        public:
     
    2727                virtual string_view get_resource_name() const { return "program"; }
    2828        protected:
    29                 virtual res_id load_resource( lua::table_guard& table );
     29                virtual bool load_resource( lua::table_guard& table, shash64 id );
    3030                string_buffer load_source( lua::table_guard& table, const string_view& append );
    31                 virtual void release( program* p );
     31                virtual void release( program p );
    3232        private:
    3333                context* m_context;
  • trunk/nv/engine/resource_system.hh

    r474 r477  
    2424{
    2525
    26         typedef uint32 res_id;
    27         typedef uint32 res_type_id;
     26        template < typename T, bool Heap = true >
     27        struct resource_storage_policy;
     28
     29        template < typename T >
     30        struct resource_storage_policy< T, true >
     31        {
     32                typedef T* type;
     33                static void free( T* value ) { delete value; }
     34                static T* to_pointer( T* value ) { return value; }
     35        };
     36
     37        template < typename T >
     38        struct resource_storage_policy< T, false >
     39        {
     40                typedef T type;
     41                static void free( T ) {}
     42                static T* to_pointer( T& value ) { return &value; }
     43        };
    2844
    2945        class resource_system;
    3046
    31         class resource_manager_base : public resource_handler
     47        class custom_resource_manager_base : public resource_handler
    3248        {
    33         public:
    34                 resource_manager_base() : m_lua( nullptr ) {}
     49        public:
     50                custom_resource_manager_base() {}
     51                virtual void clear() = 0;
     52                virtual bool load_resource( const string_view& id ) = 0;
     53        protected:
     54                virtual void unlock( resource_id, resource_type_id ) {};
     55                virtual void release( resource_id, resource_type_id ) {};
     56        };
     57
     58        class lua_resource_manager_base : public resource_handler
     59        {
     60        public:
     61                lua_resource_manager_base() : m_lua( nullptr ) {}
    3562                void initialize( lua::state* state );
    3663                virtual string_view get_storage_name() const = 0;
    3764                virtual string_view get_resource_name() const = 0;
    38                 virtual void clear() { m_names.clear(); }
     65                virtual void clear() = 0;
    3966                void load_all();
    40                 res_id load_resource( const string_view& id );
    41                 virtual ~resource_manager_base() {}
     67                bool load_resource( const string_view& id );
     68                virtual ~lua_resource_manager_base() {}
    4269        protected:
    43                 virtual res_id load_resource( lua::table_guard& table ) = 0;
    44 
    45 //              virtual const void* lock( resource_id id, resource_type_id );
     70                virtual bool load_resource( lua::table_guard& table, shash64 id ) = 0;
     71                //              virtual const void* lock( resource_id id, resource_type_id );
    4672                virtual void unlock( resource_id, resource_type_id ) {};
    4773                virtual void release( resource_id, resource_type_id ) {};
    4874
    4975                lua::state* m_lua;
    50                 hash_store< shash64, res_id > m_names;
    5176        };
    5277
    53         template < typename T >
    54         class resource_manager : public resource_manager_base
     78        template < typename T, bool Heap = true, typename Base = custom_resource_manager_base >
     79        class custom_resource_manager : public Base
    5580        {
    5681        public:
    57                 resource_manager() { m_data.push_back(nullptr); }
    58                 T* get_resource( res_id id )
     82                typedef resource_storage_policy< T, Heap > policy_type;
     83                typedef T                          value_type;
     84                typedef resource< T >              resource_type;
     85                typedef typename policy_type::type stored_type;
     86
     87                custom_resource_manager() {}
     88                resource_type get( const string_view& id )
    5989                {
    60                         return ( id < m_data.size() ? m_data[ id ] : nullptr );
    61                 }
    62                 T* get_resource( const string_view& id )
    63                 {
    64                         auto m = m_names.find( id );
    65                         if ( m != m_names.end() )
    66                         {
    67                                 return get_resource( m->second );
    68                         }
    69                         return get_resource( load_resource( id ) );
    70                 }
    71                 resource< T > get( const string_view& id )
    72                 {
    73                         auto m = m_names.find( id );
    74                         if ( m != m_names.end() )
     90                        auto m = m_store.find( id );
     91                        if ( m != m_store.end() )
    7592                        {
    7693                                return create< T >( id );
     
    7895                        else
    7996                        {
    80                                 if ( get_resource( id ) != nullptr )
     97                                if ( this->load_resource( id ) )
    8198                                {
    8299                                        return create< T >( id );
    83100                                }
    84101                        }
    85 //                      NV_ASSERT( false, "resource_manager.get failed!" );
    86                         return resource<T>();
     102                        // NV_ASSERT( false, "resource_manager.get failed!" );
     103                        return resource_type();
    87104                }
     105
     106                resource_type get( uint64 id )
     107                {
     108                        auto m = m_store.find( shash64( id ) );
     109                        if ( m != m_store.end() )
     110                        {
     111                                return create< T >( shash64( id ) );
     112                        }
     113                        // NV_ASSERT( false, "resource_manager.get failed!" );
     114                        return resource_type();
     115                }
     116
     117
    88118                virtual void clear()
    89119                {
    90                         resource_manager_base::clear();
    91                         for ( uint32 i = 1; i < m_data.size(); ++i )
    92                                 release( m_data[i] );
    93                         m_data.clear();
    94                         m_data.push_back( nullptr );
     120                        for ( auto data : m_store )
     121                        {
     122                                release( data.second );
     123                                policy_type::free( data.second );
     124                        }
     125                        m_store.clear();
    95126                }
    96127
    97                 virtual ~resource_manager()
     128                virtual ~custom_resource_manager()
    98129                {
    99130                        clear();
     
    102133                virtual const void* lock( resource_id id, resource_type_id )
    103134                {
    104                         auto m = m_names.find( id );
    105                         if ( m != m_names.end() )
    106                         {
    107                                 return m_data[m->second];
    108                         }
    109                         return nullptr;
     135                        auto m = m_store.find( id );
     136                        return m != m_store.end() ? policy_type::to_pointer( m->second ) : nullptr;
    110137                }
    111138
    112                 virtual void release( T* ) {}
     139                virtual void release( stored_type ) {}
    113140
    114                 res_id add( T* resource )
     141                void add( stored_type resource, shash64 id )
    115142                {
    116                         m_data.push_back( resource );
    117                         return m_data.size() - 1;
     143                        m_store[id] = resource;
    118144                }
    119145
    120                 vector< T* > m_data;
     146                hash_store< shash64, stored_type > m_store;
    121147        };
    122        
     148
     149        template < typename T, bool Heap = true >
     150        using lua_resource_manager = custom_resource_manager< T, Heap, lua_resource_manager_base >;
     151
    123152}
    124153
  • trunk/nv/gfx/skeletal_mesh.hh

    r475 r477  
    2020        {
    2121        public:
    22                 skeletal_animation_entry( shash64 name, const mesh_nodes_data* anim, bool a_looping )
    23                         : animation_entry( name, a_looping, anim->get_fps(), 0, anim->get_frame_count() )
    24                         , m_data( anim )
     22                skeletal_animation_entry( shash64 name, const mesh_nodes_data* anim, uint32 fps, uint32 time_start, uint32 time_end, bool a_looping )
     23                        : animation_entry( name, a_looping, fps, time_start, time_end )
     24                        , m_temp_anim( anim )
    2525                {
    2626                }
    27 
    28                 skeletal_animation_entry( shash64 name, const mesh_nodes_data* anim, uint32 time_start, uint32 time_end, bool a_looping )
    29                         : animation_entry( name, a_looping, anim->get_fps(), time_start, time_end )
    30                         , m_data( anim )
    31 
    32                 {
    33                 }
    34 
     27                const skeleton_binding& get_binding() const { return m_data; }
    3528                void prepare( const mesh_nodes_data* bones );
    36                 void update_skeleton( mat4* tr, uint32 a_ms_time ) const;
     29                void update_skeleton( skeleton_instance& tr, uint32 a_ms_time ) const;
    3730               
    3831        protected:
    39                 skeleton_instance m_data;
     32                const mesh_nodes_data* m_temp_anim;
     33                skeleton_binding m_data;
    4034        };
    4135
     
    4640                virtual vertex_array get_vertex_array() const { return m_va; }
    4741                virtual size_t get_index_count() const { return m_index_count; }
    48                 virtual void run_animation( animation_entry* a_anim )
     42                virtual void run_animation( animation_entry& a_anim )
    4943                {
    5044                        update_animation( a_anim, 0 );
    5145                }
    52                 virtual void update( program a_program );
    53                 virtual void update_animation( animation_entry* a_anim, uint32 a_anim_time );
     46                virtual void update_program( program a_program );
     47                virtual void update_animation( animation_entry& a_anim, uint32 a_anim_time );
    5448                virtual transform get_node_transform( uint32 node_id ) const;
    5549                virtual mat4 get_node_matrix( uint32 node_id ) const;
    5650                virtual sint16 get_parent_id() const { return m_parent_id; }
    57                 virtual uint32 get_node_count() const { return m_bone_data ? m_bone_data->size() : 0; }
     51                virtual uint32 get_node_count() const { return m_skeleton.size(); }
     52                skeleton_instance& get_skeleton() { return m_skeleton; }
     53                const mesh_nodes_data* get_bone_data() { return m_bone_data; }
     54                context* get_context() { return m_context;  }
    5855                ~skeletal_mesh()
    5956                {
    6057                        m_context->release( m_va );
    61                         delete[] m_transform;
    6258                }
    6359        protected:
     60                skeleton_instance m_skeleton;
    6461                vertex_array m_va;
     62                uint32       m_index_count;
    6563                context*     m_context;
    66                 data_descriptor m_interpolation_key;
    6764                const mesh_nodes_data* m_bone_data;
    68                 uint32 m_index_count;
    69                 mat4*  m_transform;
    7065                sint16 m_parent_id;
    7166        };
  • trunk/nv/gfx/skeleton_instance.hh

    r475 r477  
    99
    1010#include <nv/common.hh>
     11#include <nv/stl/array.hh>
    1112#include <nv/interface/context.hh>
    1213#include <nv/interface/mesh_data.hh>
     
    1516{
    1617
    17         class skeleton_instance
     18        class skeleton_binding
    1819        {
    1920        public:
    20                 explicit skeleton_instance( const mesh_nodes_data* data )
    21                         : m_data( data )
    22                         , m_indices( nullptr )
     21                explicit skeleton_binding()
     22                        : m_indices( nullptr )
    2323                        , m_offsets( nullptr )
    2424                {
    2525                }
    26                 void prepare( const mesh_nodes_data* data );
    27                 void animate( mat4* data, float frame ) const;
    28                 ~skeleton_instance()
     26                void prepare( const mesh_nodes_data* node_data, const mesh_nodes_data* bone_data );
     27                ~skeleton_binding()
    2928                {
    3029                        delete[] m_indices;
     
    3231                }
    3332        protected:
    34                 void animate_rec( mat4* data, float frame, uint32 id, const mat4& parent ) const;
    35                 void animate_flat( mat4* data, float frame ) const;
    36 
    37                 const mesh_nodes_data* m_data;
    3833                sint16*                m_indices;
    3934                mat4*                  m_offsets;
    4035                data_descriptor        m_key;
     36
     37                friend class skeleton_instance;
    4138        };
     39
     40        class skeleton_instance
     41        {
     42        public:
     43                explicit skeleton_instance( uint32 bone_count )
     44                {
     45                        initialize( bone_count );
     46                }
     47                void initialize( uint32 bone_count )
     48                {
     49                        if ( bone_count > m_transform.size() )
     50                                m_transform.resize( bone_count );
     51                }
     52                const mat4* transforms() const { return m_transform.data(); }
     53                size_t size() const { return m_transform.size(); }
     54
     55                void animate( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame );
     56        protected:
     57                void animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const mat4& parent );
     58                void animate_flat( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame );
     59
     60                dynamic_array< mat4 > m_transform;
     61};
     62
    4263
    4364}
  • trunk/nv/interface/animated_mesh.hh

    r471 r477  
    5656        public:
    5757                animated_mesh() {}
    58                 virtual void update_animation( animation_entry*, uint32 ) {}
    59                 virtual void run_animation( animation_entry* ) {}
     58                virtual void update_animation( animation_entry&, uint32 ) {}
     59                virtual void run_animation( animation_entry& ) {}
    6060                virtual transform get_node_transform( uint32 ) const { return transform(); }
    6161                virtual mat4 get_node_matrix( uint32 ) const { return mat4(); }
  • trunk/nv/interface/context.hh

    r473 r477  
    4949        public:
    5050                mesh_interface() {}
    51                 virtual void update( program ) {}
     51                virtual void update_program( program ) {}
    5252                virtual nv::vertex_array get_vertex_array() const = 0;
    5353                virtual size_t get_index_count() const = 0;
  • trunk/nv/interface/mesh_data.hh

    r475 r477  
    9797                }
    9898
     99                bool is_animated() const
     100                {
     101                        for ( auto data : m_data )
     102                        {
     103                                if ( data->size() > 0 ) return true;
     104                        }
     105                        return false;
     106                }
     107
    99108                const data_channel_set* get_by_hash( shash64 h ) const
    100109                {
     
    168177                }
    169178                uint32 get_count() const { return m_count; }
     179                data_channel_set* release_meshes() { data_channel_set* meshes = m_meshes; m_meshes = nullptr; return meshes; }
     180                mesh_nodes_data* release_nodes() { mesh_nodes_data* nodes = m_nodes; m_nodes = nullptr; return nodes; }
    170181                const mesh_nodes_data* get_nodes() const { return m_nodes; }
    171182                uint32 get_node_count() const { return m_nodes ? m_nodes->size() : 0; }
  • trunk/src/engine/program_manager.cc

    r474 r477  
    1616}
    1717
    18 nv::res_id nv::program_manager::load_resource( lua::table_guard& table )
     18bool nv::program_manager::load_resource( lua::table_guard& table, shash64 id )
    1919{
    2020        NV_LOG_DEBUG( table.get_string("id") );
     
    3636        }
    3737
    38         nv::program* program = new nv::program( m_context->get_device()->create_program( vsource, fsource ) );
    39         return add( program );
     38        add( m_context->get_device()->create_program( vsource, fsource ), id );
     39        return true;
    4040}
    4141
    42 void nv::program_manager::release( program* p )
     42void nv::program_manager::release( program p )
    4343{
    44         m_context->get_device()->release( *p );
    45         delete p;
     44        m_context->get_device()->release( p );
    4645}
    4746
  • trunk/src/engine/resource_system.cc

    r474 r477  
    99#include "nv/lua/lua_nova.hh"
    1010
    11 void nv::resource_manager_base::initialize( lua::state* a_lua_state )
     11void nv::lua_resource_manager_base::initialize( lua::state* a_lua_state )
    1212{
    1313        m_lua = a_lua_state;
     
    1616}
    1717
    18 nv::res_id nv::resource_manager_base::load_resource( const string_view& id )
     18bool nv::lua_resource_manager_base::load_resource( const string_view& id )
    1919{
    2020        lua::table_guard table( m_lua, lua::path( get_storage_name(), id ) );
    21         res_id rid = load_resource( table );
    22         if ( rid != 0 ) m_names[ id ] = rid;
    23         return rid;
     21        load_resource( table, id );
     22        return true;
    2423}
    2524
    26 void nv::resource_manager_base::load_all()
     25void nv::lua_resource_manager_base::load_all()
    2726{
    2827        clear();
     
    3130        for ( auto i : range( count ) )
    3231        {
    33                 lua::table_guard sub_table( table, i+1 );
    34                 res_id rid = load_resource( sub_table );
    35                 if ( rid != 0 ) m_names[ sub_table.get_string_hash_64("id") ] = rid;
     32                lua::table_guard sub_table( table, i + 1 );
     33                load_resource( sub_table, sub_table.get_string_hash_64( "id" ) );
    3634        }
    3735}
     36
  • 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}
  • trunk/src/gfx/skeleton_instance.cc

    r475 r477  
    77#include "nv/gfx/skeleton_instance.hh"
    88
    9 void nv::skeleton_instance::prepare( const mesh_nodes_data* bones )
     9void nv::skeleton_binding::prepare( const mesh_nodes_data* node_data, const mesh_nodes_data* bone_data )
    1010{
    11         if ( m_offsets || m_indices ) return;
    12         hash_store< shash64, uint16 > bone_names;
    13         m_offsets = new mat4[bones->size()];
    14         m_indices = new sint16[m_data->size()];
     11        if ( !m_offsets || !m_indices )
     12        {
     13                // TODO: either fixed size struct or static allocator
     14                hash_store< shash64, uint16 > bone_names;
     15                m_offsets = new mat4[bone_data->size()];
     16                m_indices = new sint16[node_data->size()];
    1517
    16         for ( nv::uint16 bi = 0; bi < bones->size(); ++bi )
    17         {
    18                 const data_channel_set* bone = ( *bones )[bi];
    19                 bone_names[bone->get_name()] = bi;
    20                 m_offsets[bi] = bone->get_transform();
     18                for ( nv::uint16 bi = 0; bi < bone_data->size(); ++bi )
     19                {
     20                        const data_channel_set* bone = ( *bone_data )[bi];
     21                        bone_names[bone->get_name()] = bi;
     22                        m_offsets[bi] = bone->get_transform();
     23                }
     24
     25                for ( uint32 n = 0; n < node_data->size(); ++n )
     26                {
     27                        const data_channel_set* node = ( *node_data )[n];
     28                        sint16 bone_id = -1;
     29
     30                        auto bi = bone_names.find( node->get_name() );
     31                        if ( bi != bone_names.end() )
     32                        {
     33                                bone_id = sint16( bi->second );
     34                        }
     35                        m_indices[n] = bone_id;
     36
     37                }
    2138        }
    2239
    23         for ( uint32 n = 0; n < m_data->size(); ++n )
     40        if ( m_key.size() == 0 )
    2441        {
    25                 const data_channel_set* node = ( *m_data )[n];
    26                 sint16 bone_id = -1;
     42                for ( uint32 n = 0; n < node_data->size(); ++n )
     43                        if ( ( *node_data )[n]->size() > 0 )
     44                        {
     45                                m_key = ( *node_data )[n]->get_interpolation_key();
     46                                break;
     47                        }
     48        }
    2749
    28                 auto bi = bone_names.find( node->get_name() );
    29                 if ( bi != bone_names.end() )
     50}
     51
     52void nv::skeleton_instance::animate( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame )
     53{
     54        if ( m_transform.size() > 0 )
     55        {
     56                if ( node_data->is_flat() )
    3057                {
    31                         bone_id = sint16( bi->second );
     58                        animate_flat( node_data, binding, frame );
    3259                }
    33                 m_indices[n] = bone_id;
    34 
    35                 if ( m_key.size() == 0 && node->size() > 0 )
    36                         m_key = node->get_interpolation_key();
     60                else
     61                {
     62                        for ( uint32 n = 0; n < node_data->size(); ++n )
     63                                if ( ( *node_data )[n]->get_parent_id() == -1 )
     64                                        animate_rec( node_data, binding, frame, n, mat4() );
     65                }
    3766        }
    3867}
    3968
    40 void nv::skeleton_instance::animate( mat4* data, float frame ) const
    41 {
    42         if ( m_data->is_flat() )
    43         {
    44                 animate_flat( data, frame );
    45         }
    46         else
    47         {
    48                 for ( uint32 n = 0; n < m_data->size(); ++n )
    49                         if ( ( *m_data )[n]->get_parent_id() == -1 )
    50                                 animate_rec( data, frame, n, mat4() );
    51         }
    52 }
    53 
    54 void nv::skeleton_instance::animate_flat( mat4* data, float frame ) const
    55 {
    56         for ( uint32 n = 0; n < m_data->size(); ++n )
    57                 if ( m_indices[n] >= 0 )
    58                 {
    59                         const data_channel_set* node = ( *m_data )[n];
    60                         nv::mat4 node_mat( node->get_transform() );
    61 
    62                         if ( node->size() > 0 )
    63                         {
    64                                 raw_channel_interpolator interpolator( node, m_key );
    65                                 node_mat = interpolator.get< mat4 >( frame );
    66                         }
    67 
    68                         sint16 bone_id = m_indices[n];
    69                         data[bone_id] = node_mat * m_offsets[bone_id];
    70                 }
    71 }
    72 
    73 void nv::skeleton_instance::animate_rec( mat4* data, float frame, uint32 id, const mat4& parent ) const
     69void nv::skeleton_instance::animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const mat4& parent )
    7470{
    7571        // TODO: fix transforms, which are now embedded,
    7672        //       see note in assimp_loader.cc:load_node
    77         const data_channel_set* node = ( *m_data )[id];
     73        const data_channel_set* node = ( *node_data )[id];
    7874        mat4 node_mat( node->get_transform() );
    7975
    8076        if ( node->size() > 0 )
    8177        {
    82                 raw_channel_interpolator interpolator( node, m_key );
     78                raw_channel_interpolator interpolator( node, binding.m_key );
    8379                node_mat = interpolator.get< mat4 >( frame );
    8480        }
     
    8682        mat4 global_mat = parent * node_mat;
    8783
    88         sint16 bone_id = m_indices[id];
     84        sint16 bone_id = binding.m_indices[id];
    8985        if ( bone_id >= 0 )
    9086        {
    91                 data[bone_id] = global_mat * m_offsets[bone_id];
     87                m_transform[bone_id] = global_mat * binding.m_offsets[bone_id];
    9288        }
    9389
    94         for ( auto child : m_data->children( id ) )
     90        for ( auto child : node_data->children( id ) )
    9591        {
    96                 animate_rec( data, frame, child, global_mat );
     92                animate_rec( node_data, binding, frame, child, global_mat );
    9793        }
    9894}
     95
     96void nv::skeleton_instance::animate_flat( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame )
     97{
     98        for ( uint32 n = 0; n < node_data->size(); ++n )
     99                if ( binding.m_indices[n] >= 0 )
     100                {
     101                        const data_channel_set* node = ( *node_data )[n];
     102                        nv::mat4 node_mat( node->get_transform() );
     103
     104                        if ( node->size() > 0 )
     105                        {
     106                                raw_channel_interpolator interpolator( node, binding.m_key );
     107                                node_mat = interpolator.get< mat4 >( frame );
     108                        }
     109
     110                        sint16 bone_id = binding.m_indices[n];
     111                        m_transform[bone_id] = node_mat * binding.m_offsets[bone_id];
     112                }
     113}
  • trunk/src/gl/gl_device.cc

    r473 r477  
    389389                glGetProgramInfoLog( p->glid, buffer_size, &length, buffer );
    390390                NV_LOG_ERROR( "Program #", p->glid, " validation error : ", buffer );
    391                 return false;
     391                //return false;
    392392        }
    393393        load_attributes( p );
Note: See TracChangeset for help on using the changeset viewer.