Changeset 410


Ignore:
Timestamp:
07/08/15 17:33:38 (10 years ago)
Author:
epyon
Message:
  • merge of vertex_descriptor and key_descriptor concepts - unified raw data description via data_descriptor
  • minor bugfixes
Location:
trunk
Files:
1 added
2 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv.lua

    r396 r410  
    147147
    148148        configuration "vs*"
    149                 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1", "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" }
     149                defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" } --, "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" }
    150150
    151151if _ACTION == "gmake-clang" then
  • trunk/nv/core/arcball.hh

    r398 r410  
    6565                                p.z = sqrt( 1.0f - sq );
    6666                        else
    67                                 p = math::normalize( p );
     67                                p = glm::normalize( p );
    6868                        return p;
    6969                }
  • trunk/nv/formats/nmd_loader.hh

    r395 r410  
    5555        };
    5656
    57         struct nmd_key_channel_header
    58         {
    59                 key_descriptor format;
    60                 uint32         count;
    61         };
    62 
    6357        struct nmd_stream_header
    6458        {
    65                 vertex_descriptor format;
    66                 uint32 count;
     59                data_descriptor format;
     60                uint32          count;
    6761        };
    6862
  • trunk/nv/formats/obj_loader.hh

    r395 r410  
    3232                ~obj_loader();
    3333        private:
    34                 vertex_descriptor    m_descriptor;
     34                data_descriptor      m_descriptor;
    3535                bool                 m_normals;
    3636                bool                 m_tangents;
  • trunk/nv/gfx/animation.hh

    r406 r410  
    1212#include <nv/interface/stream.hh>
    1313#include <nv/stl/math.hh>
    14 #include <nv/interface/animation_key.hh>
     14#include <nv/interface/data_descriptor.hh>
    1515#include <nv/interface/interpolation_raw.hh>
    1616#include <nv/interface/interpolation_template.hh>
     
    2222        struct key_raw_channel
    2323        {
    24                 key_descriptor desc;
    25                 uint8*         data;
    26                 uint32         count;
     24                data_descriptor desc;
     25                uint8*          data;
     26                uint32          count;
    2727
    2828                key_raw_channel() : data( nullptr ), count( 0 ) {}
     
    3232                }
    3333
    34                 uint32 size() const { return count * desc.size; }
     34                uint32 size() const { return count * desc.element_size(); }
    3535
    3636                template < typename KEY >
     
    4444                }
    4545
    46                 static key_raw_channel* create( const key_descriptor& keydesc, uint32 count = 0 )
     46                static key_raw_channel* create( const data_descriptor& keydesc, uint32 count = 0 )
    4747                {
    4848                        key_raw_channel* result = new key_raw_channel();
     
    5656                {
    5757                        if ( count == 0 ) return 0;
    58                         uint32 keyfsize   = desc.size / 4;
     58                        uint32 keyfsize   = desc.element_size() / 4;
    5959                        const float* fdata = reinterpret_cast<const float*>( data ) + keyfsize * index;
    6060                        uint32 mod        = 0;
    61                         if ( desc.slots[0].vslot == animation_slot::TIME ) mod = 1;
     61                        if ( desc[0].vslot == slot::TIME ) mod = 1;
    6262                        raw_copy_n( fdata + mod, keyfsize - mod, result );
    6363                        return keyfsize - mod;
     
    6767                {
    6868                        if ( count == 0 ) return 0;
    69                         uint32 keyfsize   = desc.size / 4;
     69                        uint32 keyfsize   = desc.element_size() / 4;
    7070                        uint32 keyfresult = keyfsize;
    7171                        const float* fdata = reinterpret_cast<const float*>( data );
     
    7575                        int index1  = -1;
    7676                        float factor = 1.0f;
    77                         if ( desc.slots[0].vslot == animation_slot::TIME )
    78                         {
    79                                 NV_ASSERT( desc.slots[0].offset == 0, "time offset not zero!" );
     77                        if ( desc[0].vslot == slot::TIME )
     78                        {
     79                                NV_ASSERT( desc[0].offset == 0, "time offset not zero!" );
    8080                                slot++;
    8181                                keyfresult--;
     
    112112                        }
    113113                        uint32 ret = 0;
    114                         for ( ; slot < desc.count; ++slot )
     114                        for ( ; slot < desc.slot_count(); ++slot )
    115115                        {
    116116                                ret += nv::interpolate_raw(
    117                                         desc.slots[slot], factor,
    118                                         fdata + index0 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4,
    119                                         fdata + index1 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4,
     117                                        desc[slot], factor,
     118                                        fdata + index0 * static_cast<int>( keyfsize ) + desc[slot].offset / 4,
     119                                        fdata + index1 * static_cast<int>( keyfsize ) + desc[slot].offset / 4,
    120120                                        result + ret );
    121121                        }
     
    133133                        NV_ASSERT( channel, "nullptr passed to add_channel!" );
    134134                        m_channels.push_back( channel );
    135                         for ( uint16 i = 0; i < channel->desc.count; ++i )
    136                         {
    137                                 const key_descriptor_slot& ksi = channel->desc.slots[i];
    138                                 if ( ksi.vslot != animation_slot::TIME )
    139                                 {
    140                                         uint32 index = m_final_key.count;
    141                                         m_final_key.slots[ index ].offset = m_final_key.size;
    142                                         m_final_key.slots[ index ].etype  = ksi.etype;
    143                                         m_final_key.slots[ index ].vslot  = ksi.vslot;
    144                                         m_final_key.size += get_datatype_info( ksi.etype ).size;
    145                                         m_final_key.count++;
    146                                 }
    147                         }
     135                        for ( const auto& cslot : channel->desc )
     136                                if ( cslot.vslot != slot::TIME )
     137                                        m_final_key.push_slot( cslot.etype, cslot.vslot );
    148138                }
    149139
     
    194184                size_t get_channel_count() const { return m_channels.size(); }
    195185                const key_raw_channel* get_channel( size_t index ) const { return m_channels[ index ]; }
    196                 const key_descriptor& get_final_key() const { return m_final_key; }
     186                const data_descriptor& get_final_key() const { return m_final_key; }
    197187
    198188                virtual ~key_data()
     
    201191                }
    202192        private:
    203                 key_descriptor m_final_key;
     193                data_descriptor m_final_key;
    204194                vector< key_raw_channel* > m_channels;
    205195        };
     
    219209                {
    220210                        m_data = data;
    221                         key_descriptor desc;
     211                        data_descriptor desc;
    222212                        desc.initialize<KEY>();
    223213                        NV_ASSERT( data->desc == desc, "Bad channel passed!" );
     
    251241                {
    252242                        m_data = data;
    253                         key_descriptor desc;
     243                        data_descriptor desc;
    254244                        desc.initialize<KEY>();
    255245                        NV_ASSERT( data->desc == desc, "Bad channel passed!" );
     
    366356                explicit transform_vector( const key_raw_channel* channel )
    367357                {
    368                         key_descriptor kd;
     358                        data_descriptor kd;
    369359                        kd.initialize<key>();
    370360                        NV_ASSERT( kd == channel->desc, "bad channel!" );
  • trunk/nv/gfx/skeletal_mesh.hh

    r395 r410  
    106106                virtual transform get_node_transform( uint32 node_id ) const;
    107107                virtual mat4 get_node_matrix( uint32 node_id ) const;
    108                 ~skeletal_mesh_gpu() { delete m_transform; }
     108                ~skeletal_mesh_gpu() { delete[] m_transform; }
    109109        protected:
    110110                const mesh_nodes_data* m_bone_data;
  • trunk/nv/interface/context.hh

    r406 r410  
    132132                void add_vertex_buffer_impl( vertex_array va, buffer vb, const true_type& )
    133133                {
    134                         typedef vertex_slot_info< VTX, SLOT > vinfo;
     134                        typedef slot_info< VTX, SLOT > vinfo;
    135135                        typedef datatype_traits< typename vinfo::value_type > dt_traits;
    136136                        add_vertex_buffer( va, SLOT, vb, type_to_enum< typename dt_traits::base_type >::type, dt_traits::size, vinfo::offset, sizeof( VTX ), false );
     
    140140                void add_vertex_buffer( vertex_array va, buffer vb )
    141141                {
    142                         add_vertex_buffer_impl< VTX, SLOT >( va, vb, bool_constant< vertex_has_slot< VTX, SLOT >::value >() );
     142                        add_vertex_buffer_impl< VTX, SLOT >( va, vb, has_slot< VTX, SLOT >() );
    143143                }
    144144
     
    157157                void add_vertex_buffers( vertex_array va, buffer buf, const mesh_raw_channel* channel )
    158158                {
    159                         for ( uint32 s = 0; s < channel->desc.count; ++s )
    160                         {
    161                                 const vertex_descriptor_slot& slot = channel->desc.slots[s];
    162                                 const datatype_info& info = get_datatype_info(slot.etype);
    163                                 add_vertex_buffer( va, slot.vslot, buf, info.base , info.elements, slot.offset, channel->desc.size, false );
    164                         }
    165                 }
     159                        for ( const auto& cslot : channel->desc )
     160                        {
     161                                const datatype_info& info = get_datatype_info( cslot.etype );
     162                                add_vertex_buffer( va, cslot.vslot, buf, info.base, info.elements, cslot.offset, channel->desc.element_size(), false );
     163                        }
     164                }
     165
    166166
    167167                template < typename VTXDATA >
     
    311311                                        if ( type == INDEX_BUFFER )
    312312                                        {
    313                                                 set_index_buffer( va, b, channel->desc.slots[0].etype, true );
     313                                                set_index_buffer( va, b, channel->desc[0].etype, true );
    314314                                        }
    315315                                        else
  • trunk/nv/interface/device.hh

    r406 r410  
    113113                        : filter_min( f ), filter_max( f ), wrap_s( w ), wrap_t( w ) {}
    114114
     115        };
     116
     117        enum buffer_hint
     118        {
     119                STATIC_DRAW,
     120                STREAM_DRAW,
     121                DYNAMIC_DRAW
    115122        };
    116123
  • trunk/nv/interface/interpolation_raw.hh

    r406 r410  
    1313#include <nv/core/transform.hh>
    1414#include <nv/stl/math.hh>
    15 #include <nv/interface/animation_key.hh>
     15#include <nv/interface/data_descriptor.hh>
    1616
    1717namespace nv
     
    3333        }
    3434
    35         inline uint32 interpolate_raw( const key_descriptor_slot& slot, float factor, const float* k1, const float* k2, float* result )
     35        inline uint32 interpolate_raw( const data_descriptor_slot& slot, float factor, const float* k1, const float* k2, float* result )
    3636        {
    3737                uint32 count = get_datatype_info( slot.etype ).elements;
    3838                switch ( slot.vslot )
    3939                {
    40                 case animation_slot::TIME:     return 0;
    41                 case animation_slot::POSITION: return interpolate_raw_linear( count, factor, k1, k2, result );
    42                 case animation_slot::ROTATION: return interpolate_raw_quat( factor, k1, k2, result );
    43                 case animation_slot::SCALE:    return interpolate_raw_linear( count, factor, k1, k2, result );
    44                 case animation_slot::TFORM:    return
     40                case slot::TIME:        return 0;
     41                case slot::TRANSLATION: return interpolate_raw_linear( count, factor, k1, k2, result );
     42                case slot::ROTATION:    return interpolate_raw_quat( factor, k1, k2, result );
     43                case slot::SCALE:       return interpolate_raw_linear( count, factor, k1, k2, result );
     44                case slot::TFORM:       return
    4545                                                                                   interpolate_raw_linear( 3, factor, k1, k2, result ) +
    4646                                                                                   interpolate_raw_quat( factor, k1 + 3, k2 + 3, result + 3 );
     
    5757        }
    5858
    59         inline mat4 extract_matrix_raw( const key_descriptor& desc, const float* data )
     59        inline mat4 extract_matrix_raw( const data_descriptor& desc, const float* data )
    6060        {
    61                 if ( desc.count == 1 )
     61                if ( desc.slot_count() == 1 )
    6262                {
    63                         switch ( desc.slots[0].vslot )
     63                        switch ( desc[0].vslot )
    6464                        {
    65                         case animation_slot::TIME:     return mat4();
    66                         case animation_slot::POSITION: return glm::translate( mat4(), make_vec3( data ) );
    67                         case animation_slot::ROTATION: return mat4_cast( make_quat_fixed( data ) );
    68                         case animation_slot::SCALE:    return glm::scale( mat4(),make_vec3( data ) );
    69                         case animation_slot::TFORM:    return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract();
     65                        case slot::TIME:        return mat4();
     66                        case slot::TRANSLATION: return glm::translate( mat4(), make_vec3( data ) );
     67                        case slot::ROTATION:    return mat4_cast( make_quat_fixed( data ) );
     68                        case slot::SCALE:       return glm::scale( mat4(),make_vec3( data ) );
     69                        case slot::TFORM:       return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract();
    7070                        default:
    7171                                return mat4();
     
    7474                else
    7575                {
    76                         mat4 position;
     76                        mat4 translation;
    7777                        mat4 rotation;
    7878                        mat4 scale;
    79                         for ( uint32 i = 0; i < desc.count; ++i )
     79                        for ( auto& slot : desc )
    8080                        {
    81                                 uint32 offset = desc.slots[i].offset / 4;
    82                                 switch ( desc.slots[i].vslot )
     81                                uint32 offset = slot.offset / 4;
     82                                switch ( slot.vslot )
    8383                                {
    84                                 case animation_slot::TIME:     break;
    85                                 case animation_slot::POSITION:
    86                                         position = glm::translate( position,make_vec3( data + offset ) ); break;
    87                                 case animation_slot::ROTATION:
     84                                case slot::TIME:     break;
     85                                case slot::TRANSLATION:
     86                                        translation = glm::translate( translation,make_vec3( data + offset ) ); break;
     87                                case slot::ROTATION:
    8888                                        rotation = mat4_cast( make_quat_fixed( data + offset ) ); break;
    89                                 case animation_slot::SCALE:   
     89                                case slot::SCALE:   
    9090                                        scale    = glm::scale( mat4(),make_vec3( data + offset ) ); break;
    91                                 case animation_slot::TFORM:    return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract();
     91                                case slot::TFORM:    return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract();
    9292                                default:
    9393                                        break;
    9494                                }
    9595                        }
    96                         return position * rotation * scale;
     96                        return translation * rotation * scale;
    9797                }
    9898        }
    9999
    100         inline transform extract_transform_raw( const key_descriptor& desc, const float* data )
     100        inline transform extract_transform_raw( const data_descriptor& desc, const float* data )
    101101        {
    102                 if ( desc.count == 1 )
     102                if ( desc.slot_count() == 1 )
    103103                {
    104                         switch ( desc.slots[0].vslot )
     104                        switch ( desc[0].vslot )
    105105                        {
    106                         case animation_slot::TIME:     return transform();
    107                         case animation_slot::POSITION: return transform( make_vec3( data ) );
    108                         case animation_slot::ROTATION: return transform( make_quat_fixed( data ) );
    109                         case animation_slot::SCALE:    return transform();
    110                         case animation_slot::TFORM:    return transform( make_vec3( data ), make_quat_fixed( data + 3 ) );
     106                        case slot::TIME:        return transform();
     107                        case slot::TRANSLATION: return transform( make_vec3( data ) );
     108                        case slot::ROTATION:    return transform( make_quat_fixed( data ) );
     109                        case slot::SCALE:       return transform();
     110                        case slot::TFORM:       return transform( make_vec3( data ), make_quat_fixed( data + 3 ) );
    111111                        default:
    112112                                return transform();
     
    115115                else
    116116                {
    117                         vec3 position;
     117                        vec3 translation;
    118118                        quat rotation;
    119                         for ( uint32 i = 0; i < desc.count; ++i )
     119                        for ( auto& slot : desc )
    120120                        {
    121                                 uint32 offset = desc.slots[i].offset / 4;
    122                                 switch ( desc.slots[i].vslot )
     121                                uint32 offset = slot.offset / 4;
     122                                switch ( slot.vslot )
    123123                                {
    124                                 case animation_slot::TIME:     break;
    125                                 case animation_slot::POSITION:
    126                                         position = make_vec3( data + offset ); break;
    127                                 case animation_slot::ROTATION:
     124                                case slot::TIME:     break;
     125                                case slot::TRANSLATION:
     126                                        translation = make_vec3( data + offset ); break;
     127                                case slot::ROTATION:
    128128                                        rotation = make_quat_fixed( data + offset ); break;
    129                                 case animation_slot::SCALE:        break;
    130                                 case animation_slot::TFORM:    return transform( make_vec3( data + offset ), make_quat_fixed( data + 3 ) );
     129                                case slot::SCALE:          break;
     130                                case slot::TFORM:    return transform( make_vec3( data + offset ), make_quat_fixed( data + 3 ) );
    131131                                default:
    132132                                        break;
    133133                                }
    134134                        }
    135                         return transform( position, rotation );
     135                        return transform( translation, rotation );
    136136                }
    137137        }
    138138
    139         inline void transform_key_position( uint8* data, float scale, const mat3& r33 )
     139        inline void transform_key_translation( uint8* data, float scale, const mat3& r33 )
    140140        {
    141141                vec3& p = *( reinterpret_cast<vec3*>( data ) );
     
    161161        }
    162162
    163         inline void transform_key_raw( const key_descriptor& desc, uint8* data, float scale, const mat3& r33, const mat3& ri33 )
     163        inline void transform_key_raw( const data_descriptor& desc, uint8* data, float scale, const mat3& r33, const mat3& ri33 )
    164164        {
    165                 for ( uint32 i = 0; i < desc.count; ++i )
     165                for ( auto& slot : desc )
    166166                {
    167                         uint32 offset = desc.slots[i].offset;
    168                         switch ( desc.slots[i].vslot )
     167                        uint32 offset = slot.offset / 4;
     168                        switch ( slot.vslot )
    169169                        {
    170                         case animation_slot::TIME:     break;
    171                         case animation_slot::POSITION: transform_key_position( data + offset, scale, r33 ); break;
    172                         case animation_slot::ROTATION: transform_key_rotation( data + offset, r33, ri33 ); break;
    173                         case animation_slot::SCALE:    transform_key_scale( data + offset, scale ); break;
    174                         case animation_slot::TFORM:    transform_key_transform( data + offset, scale, r33, ri33 ); break;
     170                        case slot::TIME:     break;
     171                        case slot::TRANSLATION: transform_key_translation( data + offset, scale, r33 ); break;
     172                        case slot::ROTATION:    transform_key_rotation( data + offset, r33, ri33 ); break;
     173                        case slot::SCALE:       transform_key_scale( data + offset, scale ); break;
     174                        case slot::TFORM:       transform_key_transform( data + offset, scale, r33, ri33 ); break;
    175175                        default:
    176176                                break;
  • trunk/nv/interface/interpolation_template.hh

    r395 r410  
    1313#include <nv/core/transform.hh>
    1414#include <nv/stl/math.hh>
    15 #include <nv/interface/animation_key.hh>
     15#include <nv/interface/data_descriptor.hh>
    1616
    1717namespace nv
    1818{
    1919
    20         template < typename KEY, animation_slot SLOT >
    21         void interpolate_slot( KEY& key, const KEY& k1, const KEY& k2, float factor, const true_type& )
    22         {
    23                 key_slot_info< KEY, SLOT >::interpolate( key, k1, k2, factor );
    24         }
    25 
    26         template < typename KEY, animation_slot SLOT >
    27         void interpolate_slot( KEY&, const KEY&, const KEY&, float, const false_type& )
    28         {
    29         }
     20        template < typename Key, slot Slot, bool HasKey = has_slot< Key, Slot >::value >
     21        struct slot_interpolator;
     22
     23        template < typename Key, slot Slot >
     24        struct slot_interpolator< Key, Slot, false >
     25        {
     26                static void interpolate( Key&, const Key&, const Key&, float )
     27                {
     28                }
     29        };
     30
     31        template < typename Key >
     32        struct slot_interpolator< Key, slot::TRANSLATION, true >
     33        {
     34                static void interpolate( Key& key, const Key& k1, const Key& k2, float factor )
     35                {
     36                        key.translation = ::nv::interpolate( k1.translation, k2.translation, factor );
     37                }
     38        };
     39
     40        template < typename Key >
     41        struct slot_interpolator< Key, slot::ROTATION, true >
     42        {
     43                static void interpolate( Key& key, const Key& k1, const Key& k2, float factor )
     44                {
     45                        key.rotation = nv::interpolate( k1.rotation, k2.rotation, factor );
     46                }
     47        };
     48
     49        template < typename Key >
     50        struct slot_interpolator< Key, slot::SCALE, true >
     51        {
     52                static void interpolate( Key& key, const Key& k1, const Key& k2, float factor )
     53                {
     54                        key.scale = nv::interpolate( k1.scale, k2.scale, factor );
     55                }
     56        };
     57
     58        template < typename Key >
     59        struct slot_interpolator< Key, slot::TFORM, true >
     60        {
     61                static void interpolate( Key& key, const Key& k1, const Key& k2, float factor )
     62                {
     63                        key.tform = nv::interpolate( k1.tform, k2.tform, factor );
     64                }
     65        };
    3066
    3167        template < typename KEY >
    3268        void interpolate_key( KEY& key, const KEY& k1, const KEY& k2, float factor )
    3369        {
    34                 interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::POSITION >() );
    35                 interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::ROTATION >() );
    36                 interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::SCALE >() );
    37                 interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::TFORM >() );
     70                slot_interpolator< KEY, slot::TRANSLATION >::interpolate( key, k1, k2, factor );
     71                slot_interpolator< KEY, slot::ROTATION    >::interpolate( key, k1, k2, factor );
     72                slot_interpolator< KEY, slot::SCALE       >::interpolate( key, k1, k2, factor );
     73                slot_interpolator< KEY, slot::TFORM       >::interpolate( key, k1, k2, factor );
    3874        }
    3975
     
    5187
    5288                template < typename KEY >
    53                 mat4 extract_matrix_p_impl( const KEY& k ) { return glm::translate(mat4(),k.position); }
     89                mat4 extract_matrix_p_impl( const KEY& k ) { return glm::translate(mat4(),k.translation); }
    5490                template < typename KEY >
    5591                mat4 extract_matrix_r_impl( const KEY& k ) { return glm::mat4_cast( k.rotation ); }
     
    6197                        // TODO: this is obviously unoptimized
    6298                        mat4 result = glm::mat4_cast( k.rotation );
    63                         result[3] = vec4( k.position, 1.0f );
     99                        result[3] = vec4( k.translation, 1.0f );
    64100                        return result;
    65101                }
     
    75111                {
    76112                        // TODO: this is obviously unoptimized
    77                         return glm::scale(glm::translate(mat4(),k.position),k.scale);
     113                        return glm::scale(glm::translate(mat4(),k.translation),k.scale);
    78114                }
    79115                template < typename KEY >
     
    81117                {
    82118                        // TODO: this is obviously unoptimized
    83                         return glm::translate(mat4(),k.position) * glm::mat4_cast( k.rotation ) * glm::scale(mat4(),k.scale);
     119                        return glm::translate(mat4(),k.translation) * glm::mat4_cast( k.rotation ) * glm::scale(mat4(),k.scale);
    84120                }
    85121
     
    113149                transform extract_transform_pr_impl( const KEY&, const false_type&, const false_type& ) { return transform(); }
    114150                template < typename KEY >
    115                 transform extract_transform_pr_impl( const KEY& k, const true_type&, const true_type& ) { return transform( k.position, k.rotation ); }
    116                 template < typename KEY >
    117                 transform extract_transform_pr_impl( const KEY& k, const true_type&, const false_type& ) { return transform( k.position ); }
     151                transform extract_transform_pr_impl( const KEY& k, const true_type&, const true_type& ) { return transform( k.translation, k.rotation ); }
     152                template < typename KEY >
     153                transform extract_transform_pr_impl( const KEY& k, const true_type&, const false_type& ) { return transform( k.translation ); }
    118154                template < typename KEY >
    119155                transform extract_transform_pr_impl( const KEY& k, const false_type&, const true_type& ) { return transform( k.rotation ); }
     
    124160                mat4 extract_matrix_impl( const KEY& k, const true_type& )
    125161                {
    126                         static_assert( key_has_slot< KEY, animation_slot::POSITION >::value == false, "key!");
    127                         static_assert( key_has_slot< KEY, animation_slot::ROTATION >::value == false, "key!");
    128                         static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");
     162                        static_assert( has_slot< KEY, slot::TRANSLATION >::value == false, "key!");
     163                        static_assert( has_slot< KEY, slot::ROTATION >::value == false, "key!");
     164                        static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!");
    129165                        return extract_matrix_slot( k.tform );
    130166                }
     
    133169                mat4 extract_matrix_impl( const KEY& k, const false_type& )
    134170                {
    135                         static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!");
     171                        static_assert( has_slot< KEY, slot::TFORM >::value == false, "key!");
    136172                        return extract_matrix_prs( k,
    137                                 key_has_slot< KEY, animation_slot::POSITION >(),
    138                                 key_has_slot< KEY, animation_slot::ROTATION >(),
    139                                 key_has_slot< KEY, animation_slot::SCALE >()
     173                                has_slot< KEY, slot::TRANSLATION >(),
     174                                has_slot< KEY, slot::ROTATION >(),
     175                                has_slot< KEY, slot::SCALE >()
    140176                                );
    141177                }
     
    144180                transform extract_transform_impl( const KEY& k, const true_type& )
    145181                {
    146                         static_assert( key_has_slot< KEY, animation_slot::POSITION >::value == false, "key!");
    147                         static_assert( key_has_slot< KEY, animation_slot::ROTATION >::value == false, "key!");
    148                         static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");
     182                        static_assert( has_slot< KEY, slot::TRANSLATION >::value == false, "key!");
     183                        static_assert( has_slot< KEY, slot::ROTATION >::value == false, "key!");
     184                        static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!");
    149185                        return extract_transfrom_slot( k.tform );
    150186                }
     
    153189                transform extract_transform_impl( const KEY& k, const false_type& )
    154190                {
    155                         static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!");
    156                         static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");
     191                        static_assert( has_slot< KEY, slot::TFORM >::value == false, "key!");
     192                        static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!");
    157193                        return extract_transform_pr_impl( k,
    158                                 key_has_slot< KEY, animation_slot::POSITION >(),
    159                                 key_has_slot< KEY, animation_slot::ROTATION >()
     194                                has_slot< KEY, slot::TRANSLATION >(),
     195                                has_slot< KEY, slot::ROTATION >()
    160196                                );
    161197                }
     
    165201        mat4 extract_matrix( const KEY& k )
    166202        {
    167                 return detail::extract_matrix_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );
     203                return detail::extract_matrix_impl( k, has_slot< KEY, slot::TFORM >() );
    168204        }
    169205
     
    171207        transform extract_transform( const KEY& k )
    172208        {
    173                 return detail::extract_transform_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );
     209                return detail::extract_transform_impl( k, has_slot< KEY, slot::TFORM >() );
    174210        }
    175211
  • trunk/nv/interface/mesh_data.hh

    r406 r410  
    1111#include <nv/stl/math.hh>
    1212#include <nv/stl/string.hh>
     13#include <nv/interface/data_descriptor.hh>
    1314#include <nv/gfx/animation.hh>
    14 #include <nv/interface/vertex.hh>
    1515
    1616namespace nv
    1717{
    1818
     19        enum buffer_type
     20        {
     21                VERTEX_BUFFER,
     22                INDEX_BUFFER,
     23        };
     24
     25
    1926        // TODO: friend mesh_data_creator class?
    2027        // TODO: private const etc
     
    2532                friend class mesh_creator;
    2633
    27                 vertex_descriptor desc;
    28                 uint8*            data;
    29                 uint32            count;
     34                data_descriptor desc;
     35                uint8*          data;
     36                uint32          count;
    3037
    3138                mesh_raw_channel() : data( nullptr ), count( 0 ) {}
     
    3845                buffer_type get_buffer_type() const
    3946                {
    40                         if ( count > 0 && desc.slots[0].vslot == slot::INDEX )
     47                        if ( count > 0 && desc[0].vslot == slot::INDEX )
    4148                        {
    4249                                return INDEX_BUFFER;
     
    4552                }
    4653
    47                 uint32 size() const { return count * desc.size; }
     54                uint32 size() const { return count * desc.element_size(); }
    4855
    4956                template < typename VTX >
     
    5663                        return result;
    5764                }
    58                 static mesh_raw_channel* create( const vertex_descriptor& vtxdesc, uint32 count = 0 )
     65                static mesh_raw_channel* create( const data_descriptor& vtxdesc, uint32 count = 0 )
    5966                {
    6067                        mesh_raw_channel* result = new mesh_raw_channel();
     
    119126                        for ( auto ch : m_channels )
    120127                        {
    121                                 for ( uint32 i = 0; i < ch->desc.count; ++i )
    122                                         if ( ch->desc.slots[i].vslot == s )
    123                                         {
     128                                for ( auto slot : ch->desc )
     129                                        if ( slot.vslot == s )
    124130                                                return ch;
    125                                         }
    126131                        }
    127132                        return nullptr;
     
    132137                        for ( uint32 c = 0; c < m_channels.size(); ++c )
    133138                        {
    134                                 const mesh_raw_channel* ch = m_channels[c];
    135                                 for ( uint32 i = 0; i < ch->desc.count; ++i )
    136                                         if ( ch->desc.slots[i].vslot == s )
    137                                         {
     139                                for ( auto slot : m_channels[c]->desc )
     140                                        if ( slot.vslot == s )
    138141                                                return int( c );
    139                                         }
    140142                        }
    141143                        return -1;
     
    159161                const mesh_raw_channel* get_channel() const
    160162                {
    161                         vertex_descriptor compare;
     163                        data_descriptor compare;
    162164                        compare.initialize<VTX>();
    163165                        for ( auto ch : m_channels )
     
    174176                const VTX* get_channel_data() const
    175177                {
    176                         vertex_descriptor compare;
     178                        data_descriptor compare;
    177179                        compare.initialize<VTX>();
    178180                        for ( auto ch : m_channels )
  • trunk/nv/stl/container/contiguous_storage_policy.hh

    r406 r410  
    5050                fixed_storage( fixed_storage&& ) = default;
    5151                fixed_storage& operator=( fixed_storage&& ) = default;
     52
    5253        };
    5354
     
    7374                operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); }
    7475                operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); }
    75         protected:
     76
    7677                constexpr resizable_storage() : m_size( 0 ) {}
    77 
     78        protected:
    7879                // allow move
    7980                inline resizable_storage( resizable_storage&& other )
     
    8485                inline resizable_storage& operator=( resizable_storage&& other )
    8586                {
     87                        if ( m_size > 0 ) Storage::reallocate( 0, false );
    8688                        m_size = other.m_size;
    8789                        Storage::operator=( nv::move( other ) );
     
    113115                static SizeType get( SizeType requested, SizeType capacity, SizeType max_size )
    114116                {
    115                         SizeType minimum = nv::min<SizeType>( capacity, 4 );
     117                        SizeType minimum = nv::max<SizeType>( capacity, 4 );
    116118                        SizeType remaining = max_size - capacity;
    117119                        if ( remaining < requested ) return 0;
     
    142144                operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); }
    143145                operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); }
    144         protected:
     146
    145147                constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {}
    146 
     148        protected:
    147149                // allow move
    148150                inline growable_storage( growable_storage&& other )
     
    154156                inline growable_storage& operator=( growable_storage&& other )
    155157                {
     158                        if ( m_capacity > 0 ) Storage::reallocate( 0, false );
    156159                        m_size = other.m_size;
    157160                        m_capacity = other.m_capacity;
     
    172175                                {
    173176                                        m_capacity = new_capacity;
    174                                         m_size = new_size;
    175177                                }
    176178                                else return false;
     
    184186                        if ( new_capacity > m_capacity )
    185187                        {
    186                                 if ( Storage::reallocate( new_capacity, copy_needed ) )
     188                                if ( new_capacity > 0 && Storage::reallocate( new_capacity, copy_needed ) )
    187189                                {
    188190                                        m_capacity = new_capacity;
  • trunk/nv/stl/container/growing_container_handler.hh

    r401 r410  
    2828        {
    2929        public:
     30                typedef typename growing_container_handler< Storage, InitializePolicy > this_type;
    3031                typedef typename Storage::value_type value_type;
    3132                typedef typename Storage::size_type  size_type;
     33                typedef value_type*                  iterator;
     34                typedef const value_type*            const_iterator;
    3235
    3336                using sized_container_handler< Storage, InitializePolicy >::sized_container_handler;
     
    5053                        if ( Storage::try_grow( 1 ) ) construct_object( Storage::data() + Storage::size() - 1, forward<Args>( args )... );
    5154                }
     55
    5256                void pop_back()
    5357                {
     58                        InitializePolicy::destroy( Storage::data() + Storage::size() - 1 );
    5459                        Storage::try_resize( Storage::size() - 1, true );
    5560                }
    5661
     62                // TODO: implement swap_erase
     63                iterator erase( iterator position )
     64                {
     65                        iterator iend = Storage::data() + Storage::size();
     66                        InitializePolicy::destroy( position );
     67                        if ( ( position + 1 ) < iend )
     68                                raw_alias_copy( position + 1, iend, position );
     69                        Storage::try_resize( Storage::size() - 1, true );
     70                        return position;
     71                }
     72
     73                iterator erase( iterator first, iterator last )
     74                {
     75                        iterator iend = Storage::data() + Storage::size();
     76                        InitializePolicy::destroy( first, last );
     77                        iterator position = raw_alias_copy( last, iend, first );
     78                        Storage::try_resize( Storage::size() - ( last - first ), true );
     79                        return position;
     80                }
     81
     82                void append( const_iterator first, const_iterator last )
     83                {
     84                        // TODO: distance can't be called on destructive iterators - check
     85                        //   and use pushback if needed?
     86                        size_type d        = distance( first, last );
     87                        size_type old_size = Storage::size();
     88                        if ( Storage::try_grow( d ) )
     89                                InitializePolicy::copy( first, last, Storage::data() + old_size );
     90                }
     91
     92                // TODO: This can be much optimized in the grow case by copying in three parts
     93                void insert( iterator position, const value_type& value )
     94                {
     95                        iterator iend = Storage::data() + Storage::size();
     96                        if ( Storage::try_grow( 1 ) )
     97                        {
     98                                raw_alias_copy( position, iend, position + 1 );
     99                                copy_construct_object( position, value );
     100                        }
     101                }
     102
     103                // TODO: This can be much optimized in the grow case by copying in three parts
     104                void insert( iterator position, const_iterator first, const_iterator last )
     105                {
     106                        // TODO: distance can't be called on destructive iterators - check
     107                        //   and use pushback if needed?
     108                        iterator iend = Storage::data() + Storage::size();
     109                        size_type d = distance( first, last );
     110                        if ( Storage::try_grow( d ) )
     111                        {
     112                                raw_alias_copy( position, iend, position + d );
     113                                InitializePolicy::copy( first, last, position );
     114                        }
     115                }
    57116        };
    58117
  • trunk/nv/stl/string.hh

    r408 r410  
    346346        {
    347347                if ( p > this->size() ) return string_view(); // NV_THROW( out_of_range( "substr" ) );
    348                 if ( n == p || p + n > this->size() ) n = this->size() - p;
     348                if ( n == npos || n == p || p + n > this->size() ) n = this->size() - p;
    349349                return string_view( this->data() + p, n );
    350350        }
  • trunk/nv/stl/type_traits/experimental.hh

    r395 r410  
    4343
    4444#if NV_COMPILER == NV_MSVC
     45#define NV_VOID_DECLTYPE( EXPR ) ::nv::match_ptr_t< &EXPR >
    4546#define NV_GENERATE_HAS_MEMBER( MEMBER ) \
    4647template< typename, typename = nv::void_t<> > struct has_##MEMBER##_member : nv::false_type {}; \
    47 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< nv::match_ptr_t< &T::MEMBER > > > : true_type{};
     48template< typename T > struct has_##MEMBER##_member <T, nv::void_t< NV_VOID_DECLTYPE( T::MEMBER ) > > : true_type{};
    4849#else
     50#define NV_VOID_DECLTYPE( EXPR ) decltype( EXPR )
    4951#define NV_GENERATE_HAS_MEMBER( MEMBER ) \
    5052template< typename, typename = nv::void_t<> > struct has_##MEMBER##_member : nv::false_type {}; \
    51 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< decltype( T::MEMBER ) > > : true_type{};
     53template< typename T > struct has_##MEMBER##_member <T, nv::void_t< NV_VOID_DECLTYPE( T::MEMBER ) > > : true_type{};
    5254#endif
    5355
  • trunk/nv/stl/type_traits/transforms.hh

    r401 r410  
    4040
    4141                template< typename SOURCE, typename TARGET,
    42                         bool CONST = is_const<SOURCE>::value,
    43                         bool VOLATILE = is_volatile<SOURCE>::value >
     42                        bool IsConst = is_const<SOURCE>::value,
     43                        bool IsVolatile = is_volatile<SOURCE>::value >
    4444                struct match_cv
    4545                {
    46                         typedef typename cv_selector< TARGET, CONST, VOLATILE >::type type;
     46                        typedef typename cv_selector< TARGET, IsConst, IsVolatile >::type type;
    4747                };
    4848
     
    7373                template<> struct unsigned_type < signed long long > { typedef unsigned long long type; };
    7474
    75                 template < typename T, bool IS_ENUM = is_enum< T >::value >
     75                template < typename T, bool IsEnum = is_enum< T >::value >
    7676                struct make_signed_impl;
    7777
  • trunk/nv/wx/wx_canvas.hh

    r395 r410  
    3131                virtual int OnExit();
    3232                virtual bool initialize() = 0;
     33        protected:
     34                nv::logger m_logger;
    3335        };
    3436
     
    8890        public:
    8991                wx_log_text_ctrl_sink( wxTextCtrl* a_text_ctrl );
    90                 virtual void log( nv::log_level level, const std::string& message );
     92                virtual void log( nv::log_level level, const nv::string_view& message );
    9193        private:
    9294                wxTextCtrl* m_text_ctrl;
  • trunk/nv_wx.lua

    r352 r410  
    1010solution "*"
    1111        includedirs {
    12                 "C:/wxwidgets/include/msvc/",
    13                 "C:/wxwidgets/include/",
     12                "D:/Libraries/wxwidgets/include/msvc/",
     13                "D:/Libraries/wxwidgets/include/",
    1414        }
    15         libdirs { "C:/wxwidgets/lib/vc120_dll" }
     15        libdirs { "D:/Libraries/wxwidgets/lib/vc140_dll" }
    1616        defines { "__WXMSW__", "_UNICODE", "WXUSINGDLL", "wxMSVC_VERSION_AUTO" }
  • trunk/src/formats/assimp_loader.cc

    r406 r410  
    5050};
    5151
    52 struct assimp_key_p  { float time; vec3 position; };
     52struct assimp_key_p  { float time; vec3 translation; };
    5353struct assimp_key_r  { float time; quat rotation; };
    5454struct assimp_key_s  { float time; vec3 scale; };
     
    430430        for ( unsigned np = 0; np < node->mNumPositionKeys; ++np )
    431431        {
    432                 pchannel[np].time     = static_cast<float>( node->mPositionKeys[np].mTime );
    433                 pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue);
     432                pchannel[np].time        = static_cast<float>( node->mPositionKeys[np].mTime );
     433                pchannel[np].translation = assimp_vec3_cast(node->mPositionKeys[np].mValue);
    434434        }
    435435        for ( unsigned np = 0; np < node->mNumRotationKeys; ++np )
  • trunk/src/formats/nmd_loader.cc

    r406 r410  
    4444                source.read( &stream_header, sizeof( stream_header ), 1 );
    4545                mesh_raw_channel* channel = mesh_raw_channel::create( stream_header.format, stream_header.count );
    46                 source.read( channel->data, stream_header.format.size, stream_header.count );
     46                source.read( channel->data, stream_header.format.element_size(), stream_header.count );
    4747                mesh->add_channel( channel );
    4848        }
     
    126126                                source.read( &element_header, sizeof( element_header ), 1 );
    127127                                NV_ASSERT( element_header.type == nmd_type::KEY_CHANNEL, "CHANNEL expected!" );
    128                                 nv::nmd_key_channel_header cheader;
     128                                nv::nmd_stream_header cheader;
    129129                                source.read( &cheader, sizeof( cheader ), 1 );
    130130                                key_raw_channel* channel = key_raw_channel::create( cheader.format, cheader.count );
    131                                 source.read( channel->data, channel->desc.size, channel->count );
     131                                source.read( channel->data, channel->desc.element_size(), channel->count );
    132132                                kdata->add_channel( channel );
    133133                        }
     
    191191                sheader.count  = chan->count;
    192192                stream_out.write( &sheader, sizeof( sheader ), 1 );
    193                 stream_out.write( chan->data, chan->desc.size, chan->count );
     193                stream_out.write( chan->data, chan->desc.element_size(), chan->count );
    194194        }
    195195}
     
    205205                        for ( uint32 c = 0; c < node->data->get_channel_count(); ++c )
    206206                        {
    207                                 total += sizeof( nmd_element_header ) + sizeof( nmd_key_channel_header );
     207                                total += sizeof( nmd_element_header ) + sizeof( nmd_stream_header );
    208208                                total += node->data->get_channel(c)->size();
    209209                        }
     
    230230                for ( uint32 c = 0; c < chan_count; ++c )
    231231                {
    232                         chan_size += sizeof( nmd_element_header ) + sizeof( nv::nmd_key_channel_header );
     232                        chan_size += sizeof( nmd_element_header ) + sizeof( nv::nmd_stream_header );
    233233                        chan_size += node->data->get_channel(c)->size();
    234234                }
     
    252252                        eheader.type     = nmd_type::KEY_CHANNEL;
    253253                        eheader.children = 0;
    254                         eheader.size     = sizeof( nmd_key_channel_header ) + channel->size();
     254                        eheader.size     = sizeof( nmd_stream_header ) + channel->size();
    255255                        stream_out.write( &eheader, sizeof( eheader ), 1 );
    256256
    257                         nmd_key_channel_header cheader;
     257                        nmd_stream_header cheader;
    258258                        cheader.format    = channel->desc;
    259259                        cheader.count     = channel->count;
    260260                        stream_out.write( &cheader, sizeof( cheader ), 1 );
    261                         stream_out.write( channel->data, channel->desc.size, channel->count );
     261                        stream_out.write( channel->data, channel->desc.element_size(), channel->count );
    262262                }
    263263        }
  • trunk/src/gfx/keyframed_mesh.cc

    r406 r410  
    192192        buffer  ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), m_mesh_data->get_index_channel()->data );
    193193
    194         m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
     194        m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc[0].etype, true );
    195195
    196196        m_data = new uint8[ m_vertex_count * m_vsize ];
  • trunk/src/gfx/mesh_creator.cc

    r406 r410  
    5757                        size_t chan_count = old_keys->get_channel_count();
    5858                        if ( chan_count == 1
    59                                 && old_keys->get_channel(0)->desc.count == 1
    60                                 && old_keys->get_channel(0)->desc.slots[0].etype == TRANSFORM ) continue;
     59                                && old_keys->get_channel(0)->desc.slot_count() == 1
     60                                && old_keys->get_channel(0)->desc[0].etype == TRANSFORM ) continue;
    6161
    6262                        size_t max_keys = 0;
     
    7070                        new_keys->add_channel( raw_channel );
    7171                        nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(raw_channel->data);
    72                         key_descriptor final_key = old_keys->get_final_key();
     72                        data_descriptor final_key = old_keys->get_final_key();
    7373
    7474                        for ( unsigned n = 0; n < max_keys; ++n )
     
    107107                        {
    108108                                const key_raw_channel* channel = kdata->get_channel(c);
    109                                 size_t key_size = channel->desc.size;
     109                                size_t key_size = channel->desc.element_size();
    110110                                for ( size_t n = 0; n < channel->count; ++n )
    111111                                {
     
    126126        {
    127127                const mesh_raw_channel* channel = m_data->get_channel(c);
    128                 const vertex_descriptor& desc   = channel->desc;
     128                const data_descriptor&  desc    = channel->desc;
    129129                uint8* raw_data = channel->data;
    130                 uint32 vtx_size = desc.size;
     130                uint32 vtx_size = desc.element_size();
    131131                int p_offset = -1;
    132132                int n_offset = -1;
    133133                int t_offset = -1;
    134                 for ( uint32 i = 0; i < desc.count; ++i )
    135                         switch ( desc.slots[i].vslot )
    136                         {
    137                                 case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = int(desc.slots[i].offset); break;
    138                                 case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = int(desc.slots[i].offset); break;
    139                                 case slot::TANGENT  : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = int(desc.slots[i].offset); break;
     134                for ( const auto& cslot : desc )
     135                        switch ( cslot.vslot )
     136                        {
     137                                case slot::POSITION : if ( cslot.etype == FLOAT_VECTOR_3 ) p_offset = int( cslot.offset ); break;
     138                                case slot::NORMAL   : if ( cslot.etype == FLOAT_VECTOR_3 ) n_offset = int( cslot.offset ); break;
     139                                case slot::TANGENT  : if ( cslot.etype == FLOAT_VECTOR_4 ) t_offset = int( cslot.offset ); break;
    140140                                default             : break;
    141141                        }
     
    174174        if ( ch_n == -1 ) return;
    175175        mesh_raw_channel* channel = m_data->m_channels[ unsigned( ch_n ) ];
    176         for ( uint32 i = 0; i < channel->desc.count; ++i )
    177                 if ( channel->desc.slots[i].vslot == slot::NORMAL )
    178                 {
    179                         n_offset  = channel->desc.slots[i].offset;
     176        for ( const auto& cslot : channel->desc )
     177                if ( cslot.vslot == slot::NORMAL )
     178                {
     179                        n_offset  = cslot.offset;
    180180                }
    181181
    182182        for ( uint32 i = 0; i < channel->count; ++i )
    183183        {
    184                 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.size * i + n_offset );
     184                vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.element_size() * i + n_offset );
    185185                normal = -normal;
    186186        }
     
    204204        {
    205205                const mesh_raw_channel* channel = m_data->get_channel(c);
    206                 const vertex_descriptor& desc   = channel->desc;
    207                 for ( uint32 i = 0; i < desc.count; ++i )
    208                         switch ( desc.slots[i].vslot )
     206
     207                for ( const auto& cslot : channel->desc )
     208                switch ( cslot.vslot )
    209209                {
    210210                        case slot::POSITION :
    211                                 if ( desc.slots[i].etype == FLOAT_VECTOR_3 )
    212                                 {
    213                                         p_offset  = int( desc.slots[i].offset );
     211                                if ( cslot.etype == FLOAT_VECTOR_3 )
     212                                {
     213                                        p_offset  = int( cslot.offset );
    214214                                        p_channel = channel;
    215215                                }
    216216                                break;
    217                         case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 )
    218                                 {
    219                                         n_offset  = int( desc.slots[i].offset );
     217                        case slot::NORMAL   :
     218                                if ( cslot.etype == FLOAT_VECTOR_3 )
     219                                {
     220                                        n_offset  = int( cslot.offset );
    220221                                        n_channel = m_data->m_channels[ c ];
    221222                                        n_channel_index = c;
    222223                                }
    223224                                break;
    224                         case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 )
    225                                 {
    226                                         t_offset  = int( desc.slots[i].offset );
     225                        case slot::TEXCOORD :
     226                                if ( cslot.etype == FLOAT_VECTOR_2 )
     227                                {
     228                                        t_offset  = int( cslot.offset );
    227229                                        t_channel = channel;
    228230                                }
     
    230232                        case slot::INDEX    :
    231233                                {
    232                                         i_type    = desc.slots[i].etype;
     234                                        i_type    = cslot.etype;
    233235                                        i_channel = channel;
    234236                                }
     
    278280                }
    279281
    280                 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti0 + t_offset );
    281                 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti1 + t_offset );
    282                 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti2 + t_offset );
     282                const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti0 + t_offset );
     283                const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti1 + t_offset );
     284                const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti2 + t_offset );
    283285                vec2 st1 = w3 - w1;
    284286                vec2 st2 = w2 - w1;
     
    291293                        uint32 nti1 = t_channel->count * set + ti1;
    292294                        uint32 nti2 = t_channel->count * set + ti2;
    293                         vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti0 + p_offset );
    294                         vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti1 + p_offset );
    295                         vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti2 + p_offset );
     295                        vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti0 + p_offset );
     296                        vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti1 + p_offset );
     297                        vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti2 + p_offset );
    296298                        vec3 xyz1 = v3 - v1;
    297299                        vec3 xyz2 = v2 - v1;
     
    317319        for ( unsigned int i = 0; i < vtx_count; ++i )
    318320        {
    319                 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.size*i + n_offset );
     321                const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.element_size()*i + n_offset );
    320322                const vec3 t = vec3(tangents[i]);
    321323                if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
     
    335337{
    336338        NV_ASSERT( a->count == b->count, "merge_channel - bad channels!" );
    337         vertex_descriptor adesc = a->desc;
    338         vertex_descriptor bdesc = b->desc;
    339         uint32            count = a->count;
    340 
    341         vertex_descriptor desc  = a->desc;
    342         for ( uint32 i = 0; i < bdesc.count; i++ )
    343         {
    344                 desc.slots[desc.count+i] = bdesc.slots[i];
    345                 desc.slots[desc.count+i].offset += desc.size;
    346         }
    347         desc.size  += bdesc.size;
    348         desc.count += bdesc.count;
    349         uint8* data = new uint8[ count * desc.size ];
     339        data_descriptor adesc = a->desc;
     340        data_descriptor bdesc = b->desc;
     341        uint32          count = a->count;
     342
     343        data_descriptor desc  = a->desc;
     344        for ( auto bslot : bdesc )
     345        {
     346                desc.push_slot( bslot.etype, bslot.vslot );
     347        }
     348        uint8* data = new uint8[ count * desc.element_size() ];
    350349        for ( uint32 i = 0; i < count; ++i )
    351350        {
    352                 raw_copy_n( a->data + i * adesc.size, adesc.size, data + i*desc.size );
    353                 raw_copy_n( b->data + i * bdesc.size, bdesc.size, data + i*desc.size + adesc.size );
     351                raw_copy_n( a->data + i * adesc.element_size(), adesc.element_size(), data + i*desc.element_size() );
     352                raw_copy_n( b->data + i * bdesc.element_size(), bdesc.element_size(), data + i*desc.element_size() + adesc.element_size() );
    354353        }
    355354        mesh_raw_channel* result = new mesh_raw_channel;
     
    365364        if ( a->count % frame_count != 0 ) return nullptr;
    366365        if ( b->count % frame_count != 0 ) return nullptr;
    367         size_t vtx_size = a->desc.size;
     366        size_t vtx_size = a->desc.element_size();
    368367
    369368        uint8* data = new uint8[ ( a->count + b->count ) * vtx_size ];
     
    435434                if ( old->get_buffer_type() == INDEX_BUFFER )
    436435                {
    437                         switch ( old->desc.slots[0].etype )
     436                        switch ( old->desc[0].etype )
    438437                        {
    439438                        case USHORT :
  • trunk/src/gl/gl_window.cc

    r406 r410  
    104104        m_handle  = wm->adopt_window( handle );
    105105        m_hwnd    = ::GetDC( reinterpret_cast<HWND>( handle ) );
    106         m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
     106        m_context->set_viewport( nv::ivec4( 0, 0, 1, 1 ) );
    107107#else
    108108        NV_ASSERT( false, "Native GL context adoption not implemented for this platform!" );
  • trunk/src/stl/assert.cc

    r406 r410  
    55// For conditions of distribution and use, see copying.txt file in root folder.
    66
    7 #define NV_BASE_COMMON_HH
    8 #define NV_INTERNAL_INCLUDE
    9 #include "nv/base/assert.hh"
    10 #undef NV_BASE_COMMON_HH
     7#include "nv/base/common.hh"
    118#include "nv/core/logging.hh"
    129
    1310extern "C" {
    1411#if NV_COMPILER == NV_MSVC
    15         NV_NORETURN void __cdecl exit( _In_ int _Code );
     12        _ACRTIMP NV_NORETURN void __cdecl exit( _In_ int _Code );
    1613#else
    1714        void exit( int status_code ) NV_NORETURN;
  • trunk/src/wx/wx_canvas.cc

    r395 r410  
    6363}
    6464
    65 void nv::wx_log_text_ctrl_sink::log( nv::log_level level, const std::string& message )
     65void nv::wx_log_text_ctrl_sink::log( nv::log_level level, const nv::string_view& message )
    6666{
    6767        wxString str;
    68         str << timestamp() << " [" << padded_level_name( level ) << "] " << message << "\n";
     68        char stamp[16];
     69        size_t ssize = timestamp( stamp );
     70        str << stamp << " [" << padded_level_name( level ).data() << "] " << message.data() << "\n";
    6971        m_text_ctrl->AppendText( str );
    7072}
    7173
    7274nv::wx_app_base::wx_app_base()
     75        : m_logger( nv::LOG_TRACE )
    7376{
    74         static nv::logger log( nv::LOG_TRACE );
    75         log.add_sink( new nv::log_file_sink( "log.txt" ), nv::LOG_TRACE );
     77        nv::log_sink* sink = new nv::log_file_sink( "log.txt" );
     78        m_logger.add_sink( sink, nv::LOG_TRACE );
    7679        NV_LOG( nv::LOG_NOTICE, "Logging started" );
    7780}
Note: See TracChangeset for help on using the changeset viewer.