Changeset 415


Ignore:
Timestamp:
07/09/15 20:02:58 (10 years ago)
Author:
epyon
Message:
  • naming scheme for data_descriptor changed
  • channels can only be created by data_channel_creators
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/formats/md5_loader.hh

    r412 r415  
    8484                void reset();
    8585                void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_info, const array_view<transform>& base_frames, const array_view<float>& frame_data );
    86                 bool prepare_mesh( md5_vtx_pntiw* vtx_data, mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info );
     86                bool prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info );
    8787        protected:
    8888                file_type m_type;
  • trunk/nv/gfx/animation.hh

    r414 r415  
    9090                static uint32 get_raw( const raw_data_channel* channel, uint32 index, float* result )
    9191                {
    92                         if ( channel->element_count() == 0 ) return 0;
     92                        if ( channel->size() == 0 ) return 0;
    9393                        uint32 keyfsize = channel->element_size() / 4;
    9494                        const float* fdata = reinterpret_cast<const float*>( channel->raw_data() ) + keyfsize * index;
     
    102102                static uint32 interpolate_raw( const raw_data_channel* channel, float time, float* result )
    103103                {
    104                         if ( channel->element_count() == 0 ) return 0;
     104                        if ( channel->size() == 0 ) return 0;
    105105                        uint32 keyfsize = channel->element_size() / 4;
    106106                        uint32 keyfresult = keyfsize;
     
    116116                                slot++;
    117117                                keyfresult--;
    118                                 if ( channel->element_count() == 1 )
     118                                if ( channel->size() == 1 )
    119119                                {
    120120                                        raw_copy_n( fdata + 1, keyfresult, result );
    121121                                        return keyfresult;
    122122                                }
    123                                 for ( unsigned i = 1; i < channel->element_count(); i++ )
     123                                for ( unsigned i = 1; i < channel->size(); i++ )
    124124                                {
    125125                                        if ( time < fdata[i * keyfsize] )
     
    138138                        else
    139139                        {
    140                                 if ( channel->element_count() == 1 )
     140                                if ( channel->size() == 1 )
    141141                                {
    142142                                        raw_copy_n( fdata, keyfresult, result );
    143143                                        return keyfresult;
    144144                                }
    145                                 index0 = glm::clamp<int>( int( time ), 0, int( channel->element_count() ) - 2 );
     145                                index0 = glm::clamp<int>( int( time ), 0, int( channel->size() ) - 2 );
    146146                                index1 = index0 + 1;
    147147                                factor = glm::clamp<float>( time - index0, 0.0f, 1.0f );
    148148                        }
    149149                        uint32 ret = 0;
    150                         for ( ; slot < channel->descriptor().slot_count(); ++slot )
     150                        for ( ; slot < channel->descriptor().size(); ++slot )
    151151                        {
    152152                                ret += nv::interpolate_raw(
     
    187187                        NV_ASSERT( m_data, "Data is null!" );
    188188                        const KEY* keys = m_data->data_cast<KEY>( );
    189                         uint32 count = m_data->element_count();
     189                        uint32 count = m_data->size();
    190190                        if ( count == 0 ) return;
    191191                        if ( count == 1 )
     
    221221                        NV_ASSERT( m_data, "Data is null!" );
    222222                        const KEY* keys = m_data->data_cast<KEY>( );
    223                         uint32 count = m_data->element_count();
     223                        uint32 count = m_data->size();
    224224                        if ( count == 0 ) return;
    225225                        if ( count == 1 )
     
    278278                size_t size() const { return 0; } // TODO: remove?
    279279                bool empty() const {
    280                         return m_pchannel->element_count() == 0
    281                                 && m_rchannel->element_count() == 0
    282                                 && m_schannel->element_count() == 0; }
     280                        return m_pchannel->size() == 0
     281                                && m_rchannel->size() == 0
     282                                && m_schannel->size() == 0; }
    283283                virtual mat4 get_matrix( float time ) const
    284284                {
     
    306306                {
    307307                        return 3 * sizeof( size_t )
    308                                 + m_pchannel->element_count() * sizeof( key_p )
    309                                 + m_rchannel->element_count() * sizeof( key_r )
    310                                 + m_schannel->element_count() * sizeof( key_s );
     308                                + m_pchannel->size() * sizeof( key_p )
     309                                + m_rchannel->size() * sizeof( key_r )
     310                                + m_schannel->size() * sizeof( key_s );
    311311                }
    312312                ~key_vectors_prs()
     
    342342                        delete m_channel;
    343343                }
    344                 bool empty() const { return m_channel->element_count() == 0; }
    345                 size_t size() const { return m_channel->element_count(); }
     344                bool empty() const { return m_channel->size() == 0; }
     345                size_t size() const { return m_channel->size(); }
    346346                const transform& get( size_t index ) const { return m_channel->data_cast< key >()[ index ].tform; }
    347347                const transform* data() const { return &(m_channel->data_cast< key >()[0].tform); }
     
    349349                virtual uint32 raw_size() const
    350350                {
    351                         return sizeof( size_t ) + m_channel->element_count() * sizeof( key );
     351                        return sizeof( size_t ) + m_channel->size() * sizeof( key );
    352352                }
    353353
  • trunk/nv/interface/context.hh

    r412 r415  
    304304                        {
    305305                                const raw_data_channel* channel = channels[ch];
    306                                 if ( channel->element_count() > 0 )
     306                                if ( channel->size() > 0 )
    307307                                {
    308308                                        const data_descriptor& desc = channel->descriptor();
  • trunk/nv/interface/data_descriptor.hh

    r414 r415  
    222222                bool operator==( const data_descriptor& rhs ) const
    223223                {
    224                         if ( m_size  != rhs.m_size )  return false;
    225                         if ( m_count != rhs.m_count ) return false;
    226                         for ( uint32 i = 0; i < m_count; ++i )
     224                        if ( m_element_size != rhs.m_element_size )  return false;
     225                        if ( m_size != rhs.m_size ) return false;
     226                        for ( uint32 i = 0; i < m_size; ++i )
    227227                        {
    228228                                if ( m_slots[i].etype  != rhs.m_slots[i].etype )  return false;
     
    236236                void initialize()
    237237                {
    238                         m_count = 0;
     238                        m_size = 0;
    239239                        initialize_slot< Struct, slot::POSITION >();
    240240                        initialize_slot< Struct, slot::TEXCOORD >();
     
    250250                        initialize_slot< Struct, slot::SCALE >();
    251251                        initialize_slot< Struct, slot::TFORM >();
    252                         m_size = sizeof( Struct );
    253                 }
    254 
    255                 uint32 element_size() const { return m_size; }
    256                 uint32 slot_count() const { return m_count; }
     252                        m_element_size = sizeof( Struct );
     253                }
     254
     255                uint32 element_size() const { return m_element_size; }
     256                uint32 size() const { return m_size; }
    257257
    258258                bool has_slot( slot vslot ) const
     
    264264
    265265                const_iterator begin() const { return &m_slots[0]; }
    266                 const_iterator end() const { return &m_slots[m_count]; }
     266                const_iterator end() const { return &m_slots[m_size]; }
    267267
    268268                const data_descriptor_slot& operator []( uint32 i ) const
    269269                {
    270                         NV_ASSERT( i < m_count, "data_descriptor indexing failure!" );
     270                        NV_ASSERT( i < m_size, "data_descriptor indexing failure!" );
    271271                        return m_slots[i];
    272272                }
     
    274274                void push_slot( datatype etype, slot vslot )
    275275                {
    276                         m_slots[m_count].etype  = etype;
    277                         m_slots[m_count].offset = m_size;
    278                         m_slots[m_count].vslot  = vslot;
    279                         m_size += get_datatype_info( etype ).size;
    280                         m_count++;
     276                        m_slots[m_size].etype  = etype;
     277                        m_slots[m_size].offset = m_element_size;
     278                        m_slots[m_size].vslot  = vslot;
     279                        m_element_size += get_datatype_info( etype ).size;
     280                        m_size++;
    281281                }
    282282
     
    285285                        for ( const auto& dslot : desc )
    286286                        {
    287                                 m_slots[m_count].etype  = dslot.etype;
    288                                 m_slots[m_count].offset = m_size;
    289                                 m_slots[m_count].vslot  = dslot.vslot;
    290                                 m_size += get_datatype_info( dslot.etype ).size;
    291                                 m_count++;
     287                                m_slots[m_size].etype  = dslot.etype;
     288                                m_slots[m_size].offset = m_element_size;
     289                                m_slots[m_size].vslot  = dslot.vslot;
     290                                m_element_size += get_datatype_info( dslot.etype ).size;
     291                                m_size++;
    292292                        }
    293293                }
     
    304304
    305305                data_descriptor_slot m_slots[uint16( slot::MAX_STORE )];
    306                 uint32               m_count = 0;
    307306                uint32               m_size = 0;
     307                uint32               m_element_size = 0;
    308308
    309309                template < typename Struct, slot Slot >
     
    311311                {
    312312                        typedef slot_info< Struct, Slot > sinfo;
    313                         m_slots[m_count].etype = sinfo::etype;
    314                         if ( m_slots[m_count].etype != datatype::NONE )
     313                        m_slots[m_size].etype = sinfo::etype;
     314                        if ( m_slots[m_size].etype != datatype::NONE )
    315315                        {
    316                                 m_slots[m_count].vslot  = Slot;
    317                                 m_slots[m_count].offset = sinfo::offset;
    318                                 m_count++;
     316                                m_slots[m_size].vslot  = Slot;
     317                                m_slots[m_size].offset = sinfo::offset;
     318                                m_size++;
    319319                        }
    320320                }
     
    323323        struct raw_data_channel
    324324        {
    325                 raw_data_channel() : m_data( nullptr ), m_count( 0 ) {}
     325                raw_data_channel() : m_data( nullptr ), m_size( 0 ) {}
    326326                ~raw_data_channel()
    327327                {
     
    331331                const data_descriptor& descriptor() const { return m_desc;  }
    332332                uint32 element_size() const { return m_desc.element_size(); }
    333                 uint32 element_count() const { return m_count; }
    334                 uint32 raw_size() const { return m_count * m_desc.element_size(); }
     333                uint32 size() const { return m_size; }
     334                uint32 raw_size() const { return m_size * m_desc.element_size(); }
    335335                const uint8* raw_data() const { return m_data; }
    336336
     
    345345
    346346                template < typename Struct >
    347                 static raw_data_channel* create( uint32 count = 0 )
    348                 {
    349                         raw_data_channel* result = new raw_data_channel();
    350                         result->m_desc.initialize<Struct>();
    351                         result->m_count = count;
    352                         result->m_data = ( count > 0 ? ( new uint8[result->raw_size()] ) : nullptr );
    353                         return result;
    354                 }
    355                 static raw_data_channel* create( const data_descriptor& desc, uint32 count = 0 )
    356                 {
    357                         raw_data_channel* result = new raw_data_channel();
    358                         result->m_desc = desc;
    359                         result->m_count = count;
    360                         result->m_data = ( count > 0 ? ( new uint8[result->raw_size()] ) : nullptr );
    361                         return result;
    362                 }
    363 
    364                 template < typename Struct >
    365347                friend class data_channel_creator;
    366348                friend class raw_data_channel_creator;
     
    369351                uint8*          m_data;
    370352                data_descriptor m_desc;
    371                 uint32          m_count;
     353                uint32          m_size;
    372354
    373355        };
     
    378360                raw_data_channel_creator( const data_descriptor& desc, uint32 size )
    379361                {
    380                         m_channel = raw_data_channel::create( desc, size );
     362                        m_channel = new raw_data_channel();
     363                        m_channel->m_desc = desc;
     364                        m_channel->m_size = size;
     365                        m_channel->m_data = ( size > 0 ? ( new uint8[m_channel->raw_size()] ) : nullptr );
    381366                        m_owned   = true;
    382367                }
     
    388373
    389374                uint32 element_size() const { return m_channel->element_size(); }
    390                 uint32 size() const { return m_channel->element_count(); }
    391                 uint32 raw_size() const { return m_channel->element_count() * m_channel->element_size(); }
     375                uint32 size() const { return m_channel->size(); }
     376                uint32 raw_size() const { return m_channel->size() * m_channel->element_size(); }
    392377                uint8* raw_data() { return m_channel->m_data; }
    393378                const uint8* raw_data() const { return m_channel->m_data; }
     
    428413                const Struct& operator []( uint32 i ) const
    429414                {
    430                         NV_ASSERT( i < m_channel->m_count, "data_channel_creator indexing failure!" );
     415                        NV_ASSERT( i < m_channel->m_size, "data_channel_creator indexing failure!" );
    431416                        return reinterpret_cast< const Struct* >( m_channel->m_data )[i];
    432417                }
     
    434419                Struct& operator []( uint32 i )
    435420                {
    436                         NV_ASSERT( i < m_channel->m_count, "data_channel_creator indexing failure!" );
     421                        NV_ASSERT( i < m_channel->m_size, "data_channel_creator indexing failure!" );
    437422                        return reinterpret_cast<Struct*>( m_channel->m_data )[i];
    438423                }
  • trunk/nv/interface/interpolation_raw.hh

    r410 r415  
    5959        inline mat4 extract_matrix_raw( const data_descriptor& desc, const float* data )
    6060        {
    61                 if ( desc.slot_count() == 1 )
     61                if ( desc.size() == 1 )
    6262                {
    6363                        switch ( desc[0].vslot )
     
    100100        inline transform extract_transform_raw( const data_descriptor& desc, const float* data )
    101101        {
    102                 if ( desc.slot_count() == 1 )
     102                if ( desc.size() == 1 )
    103103                {
    104104                        switch ( desc[0].vslot )
  • trunk/nv/interface/mesh_data.hh

    r413 r415  
    3535                        NV_ASSERT( channel, "nullptr passed to add_channel!" );
    3636                        m_channels.push_back( channel );
    37                         if ( channel->element_count() > 0 && channel->descriptor()[0].vslot == slot::INDEX )
     37                        if ( channel->size() > 0 && channel->descriptor()[0].vslot == slot::INDEX )
    3838                        {
    3939                                NV_ASSERT( !m_index_channel, "second index channel!" );
     
    6868
    6969
     70                // TODO: this should be "size"
    7071                size_t get_count() const
    7172                {
    72                         if ( m_index_channel ) return m_index_channel->element_count();
    73                         if ( m_channels.size() > 0 ) return m_channels[0]->element_count();
     73                        if ( m_index_channel ) return m_index_channel->size();
     74                        if ( m_channels.size() > 0 ) return m_channels[0]->size();
    7475                        return 0;
    7576                }
     
    7778                size_t get_count( size_t channel ) const
    7879                {
    79                         if ( m_channels.size() > channel ) return m_channels[channel]->element_count();
     80                        if ( m_channels.size() > channel ) return m_channels[channel]->size();
    8081                        return 0;
    8182                }
  • trunk/src/formats/assimp_loader.cc

    r413 r415  
    117117
    118118        bool skinned = mesh->mNumBones > 0;
    119         raw_data_channel* channel = nullptr;
     119
     120        data_descriptor desc;
    120121        if ( skinned )
    121                 channel = raw_data_channel::create< assimp_skinned_vtx >( mesh->mNumVertices );
     122                desc.initialize< assimp_skinned_vtx >();
    122123        else
    123                 channel = raw_data_channel::create< assimp_plain_vtx >( mesh->mNumVertices );
    124         uint8* cdata = const_cast< uint8*>( channel->raw_data() );
    125 
    126         data->add_channel( channel );
     124                desc.initialize< assimp_plain_vtx >();
     125        raw_data_channel_creator channel( desc, mesh->mNumVertices );
     126        uint8* cdata = channel.raw_data();
     127
    127128        if ( mesh->mTangents && mesh->mBitangents )
    128         for (unsigned int i=0; i<mesh->mNumVertices; i++)
    129         {
    130                 vec3 v = assimp_vec3_cast( mesh->mVertices[ i ] );
    131                 vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[ i ] ) );
    132                 vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[ i ] ) );
    133                 vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[ i ] ) );
    134                 vec2 s = assimp_st_cast( mesh->mTextureCoords[ 0 ][ i ] );
    135 
    136                 glm::vec3 t_i = glm::normalize (t - n * glm::dot (n, t));
    137                 float det = (glm::dot (glm::cross (n, t), b));
    138                 det = (det < 0.0f ? -1.0f : 1.0f );
    139                 nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
    140                 if ( skinned )
    141                         reinterpret_cast< assimp_skinned_vtx* >( cdata )[i] = assimp_skinned_vtx( v, s, n, vt );
    142                 else
    143                         reinterpret_cast< assimp_plain_vtx* >( cdata )[i] = assimp_plain_vtx( v, s, n, vt );
    144         }
     129                for ( unsigned int i = 0; i < mesh->mNumVertices; i++ )
     130                {
     131                        vec3 v = assimp_vec3_cast( mesh->mVertices[i] );
     132                        vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
     133                        vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
     134                        vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
     135                        vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] );
     136
     137                        glm::vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
     138                        float det = ( glm::dot( glm::cross( n, t ), b ) );
     139                        det = ( det < 0.0f ? -1.0f : 1.0f );
     140                        nv::vec4 vt( t_i[0], t_i[1], t_i[2], det );
     141                        if ( skinned )
     142                                reinterpret_cast<assimp_skinned_vtx*>( cdata )[i] = assimp_skinned_vtx( v, s, n, vt );
     143                        else
     144                                reinterpret_cast<assimp_plain_vtx*>( cdata )[i] = assimp_plain_vtx( v, s, n, vt );
     145                }
    145146
    146147        if ( skinned )
     
    179180                }
    180181        }
     182        data->add_channel( channel.release() );
    181183        data->add_channel( ichannel.release() );
    182184}
  • trunk/src/formats/md5_loader.cc

    r413 r415  
    137137                        assert( m_type == MESH );
    138138                        mesh_data* mesh = new mesh_data("md5_mesh");
    139                         raw_data_channel* ch_pntiw = nullptr;
    140139
    141140                        uint32 num_verts   = 0;
     
    160159                                        md5_vtx_t* tdata = nullptr;
    161160                                        {
    162                                                 data_channel_creator<md5_vtx_pnt> ch_pnt( num_verts );
    163                                                 data_channel_creator<md5_vtx_t>   ch_t( num_verts );
    164                                                 ch_pntiw = raw_data_channel::create<md5_vtx_pntiw>( num_verts );
     161                                                data_channel_creator<md5_vtx_pnt>   ch_pnt( num_verts );
     162                                                data_channel_creator<md5_vtx_t>     ch_t( num_verts );
     163                                                data_channel_creator<md5_vtx_pntiw> ch_pntiw( num_verts );
    165164                                                tdata = ch_t.data();
    166165                                                mesh->add_channel( ch_pnt.release() );
     
    168167                                                // TODO: hack to prevent rendering
    169168                                                //ch_pntiw->m_count = 0;
    170                                                 mesh->add_channel( ch_pntiw );
     169                                                mesh->add_channel( ch_pntiw.release() );
    171170                                        }
    172171                                        weight_info.resize( num_verts );
     
    236235                        }
    237236
    238                         prepare_mesh( reinterpret_cast< md5_vtx_pntiw* >( const_cast< uint8* >( ch_pntiw->raw_data() ) ), nodes, weight_info.size(), mesh, weights.data(), weight_info.data() );
     237                        prepare_mesh( nodes, weight_info.size(), mesh, weights.data(), weight_info.data() );
    239238
    240239                        m_meshes[ num_meshes ] = mesh;
     
    258257                                nodes[i].target_id = -1;
    259258                                nodes[i].data      = new key_data;
    260                                 nodes[i].data->add_channel( raw_data_channel::create< md5_key_t >( num_frames ) );
     259                                data_channel_creator< md5_key_t > fc( num_frames );
     260                                nodes[i].data->add_channel( fc.release() );
    261261                                next_line( sstream );
    262262                        }
     
    335335}
    336336
    337 bool md5_loader::prepare_mesh( md5_vtx_pntiw* vtx_data, mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info )
     337bool md5_loader::prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info )
    338338{
    339339        assert( m_type == MESH );
    340         data_channel_creator< md5_vtx_pnt > pnt( const_cast< raw_data_channel* >( mdata->get_channel< md5_vtx_pnt >() ) );
    341         md5_vtx_pnt* vtcs       = pnt.data();
     340        data_channel_creator< md5_vtx_pnt >   pnt  ( const_cast< raw_data_channel* >( mdata->get_channel< md5_vtx_pnt >() ) );
     341        data_channel_creator< md5_vtx_pntiw > pntiw( const_cast< raw_data_channel* >( mdata->get_channel< md5_vtx_pntiw >() ) );
     342        md5_vtx_pntiw* vtx_data = pntiw.data();
     343        md5_vtx_pnt* vtcs = pnt.data();
    342344
    343345        for ( uint32 i = 0; i < vtx_count; ++i )
     
    488490                        const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->raw_data() );
    489491                        transform ptr;
    490                         if ( pjoint.data->get_channel(0)->element_count() > index ) ptr = ptv[ index ];
     492                        if ( pjoint.data->get_channel(0)->size() > index ) ptr = ptv[ index ];
    491493                        vec3 rot_pos = ptr.get_orientation() * pos;
    492494
  • trunk/src/formats/nmd_loader.cc

    r413 r415  
    189189                nmd_stream_header sheader;
    190190                sheader.format = chan->descriptor();
    191                 sheader.count  = chan->element_count();
     191                sheader.count  = chan->size();
    192192                stream_out.write( &sheader, sizeof( sheader ), 1 );
    193                 stream_out.write( chan->raw_data(), chan->element_size(), chan->element_count() );
     193                stream_out.write( chan->raw_data(), chan->element_size(), chan->size() );
    194194        }
    195195}
     
    257257                        nmd_stream_header cheader;
    258258                        cheader.format    = channel->descriptor();
    259                         cheader.count     = channel->element_count();
     259                        cheader.count     = channel->size();
    260260                        stream_out.write( &cheader, sizeof( cheader ), 1 );
    261                         stream_out.write( channel->raw_data(), channel->element_size(), channel->element_count() );
     261                        stream_out.write( channel->raw_data(), channel->element_size(), channel->size() );
    262262                }
    263263        }
  • trunk/src/gfx/keyframed_mesh.cc

    r413 r415  
    2323        , m_active( false )
    2424{
    25         m_index_count  = m_mesh_data->get_index_channel()->element_count();
    26         m_vertex_count = m_mesh_data->get_channel<vertex_t>()->element_count();
     25        m_index_count  = m_mesh_data->get_index_channel()->size();
     26        m_vertex_count = m_mesh_data->get_channel<vertex_t>()->size();
    2727        m_vchannel     = m_mesh_data->get_channel<vertex_pnt>();
    2828        m_vsize        = sizeof( vertex_pnt );
     
    3434                m_vsize        = sizeof( vertex_pn );
    3535        }
    36         m_frame_count  = m_vchannel->element_count() / m_vertex_count;
     36        m_frame_count  = m_vchannel->size() / m_vertex_count;
    3737        m_pbuffer      = buffer();
    3838}
  • trunk/src/gfx/mesh_creator.cc

    r413 r415  
    1919                key_data* keys   = m_data->m_nodes[i].data;
    2020                key_data* pkeys  = ( parent_id != -1 ? m_data->m_nodes[parent_id].data : nullptr );
    21                 size_t count     = ( keys ? keys->get_channel(0)->element_count() : 0 );
    22                 size_t pcount    = ( pkeys ? pkeys->get_channel(0)->element_count() : 0 );
     21                size_t count     = ( keys ? keys->get_channel(0)->size() : 0 );
     22                size_t pcount    = ( pkeys ? pkeys->get_channel(0)->size() : 0 );
    2323                max_frames = nv::max<uint32>( count, max_frames );
    2424                if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 )
     
    5858                        size_t chan_count = old_keys->get_channel_count();
    5959                        if ( chan_count == 1
    60                                 && old_keys->get_channel(0)->descriptor().slot_count() == 1
     60                                && old_keys->get_channel(0)->descriptor().size() == 1
    6161                                && old_keys->get_channel(0)->descriptor()[0].etype == TRANSFORM ) continue;
    6262
     
    6464                        for ( size_t c = 0; c < chan_count; ++c )
    6565                        {
    66                                 max_keys = nv::max( max_keys, old_keys->get_channel(c)->element_count() );
     66                                max_keys = nv::max( max_keys, old_keys->get_channel(c)->size() );
    6767                        }
    6868
     
    7878                                for ( uint16 c = 0; c < chan_count; ++c )
    7979                                {
    80                                         size_t idx = nv::min( old_keys->get_channel(c)->element_count() - 1, n );
     80                                        size_t idx = nv::min( old_keys->get_channel(c)->size() - 1, n );
    8181                                        pkey += old_keys->get_raw( old_keys->get_channel(c), idx, pkey );
    8282                                }
     
    242242        if ( !p_channel || !n_channel || !t_channel ) return;
    243243
    244         if ( p_channel->element_count() != n_channel->element_count()
    245                 || p_channel->element_count() % t_channel->element_count() != 0
     244        if ( p_channel->size() != n_channel->size()
     245                || p_channel->size() % t_channel->size() != 0
    246246                || ( i_type != UINT && i_type != USHORT && i_type != NONE ) )
    247247        {
     
    249249        }
    250250
    251         data_channel_creator< vertex_g > g_channel( p_channel->element_count() );
     251        data_channel_creator< vertex_g > g_channel( p_channel->size() );
    252252        vec4* tangents              = &( g_channel.data()[0].tangent );
    253         vec3* tangents2             = new vec3[ p_channel->element_count() ];
    254         uint32 tri_count = i_channel ? i_channel->element_count() / 3 : t_channel->element_count() / 3;
    255         uint32 vtx_count = p_channel->element_count();
    256         uint32 sets      = p_channel->element_count() / t_channel->element_count();
     253        vec3* tangents2             = new vec3[ p_channel->size() ];
     254        uint32 tri_count = i_channel ? i_channel->size() / 3 : t_channel->size() / 3;
     255        uint32 vtx_count = p_channel->size();
     256        uint32 sets      = p_channel->size() / t_channel->size();
    257257
    258258        for ( unsigned int i = 0; i < tri_count; ++i )
     
    292292                for ( uint32 set = 0; set < sets; ++set )
    293293                {
    294                         uint32 nti0 = t_channel->element_count() * set + ti0;
    295                         uint32 nti1 = t_channel->element_count() * set + ti1;
    296                         uint32 nti2 = t_channel->element_count() * set + ti2;
     294                        uint32 nti0 = t_channel->size() * set + ti0;
     295                        uint32 nti1 = t_channel->size() * set + ti1;
     296                        uint32 nti2 = t_channel->size() * set + ti2;
    297297                        const vec3& v1 = *reinterpret_cast<const vec3*>(p_channel->raw_data() + p_channel->element_size()*nti0 + p_offset );
    298298                        const vec3& v2 = *reinterpret_cast<const vec3*>(p_channel->raw_data() + p_channel->element_size()*nti1 + p_offset );
     
    337337nv::raw_data_channel* nv::mesh_data_creator::merge_channels( raw_data_channel* a, raw_data_channel* b )
    338338{
    339         NV_ASSERT( a->element_count() == b->element_count(), "merge_channel - bad channels!" );
     339        NV_ASSERT( a->size() == b->size(), "merge_channel - bad channels!" );
    340340        data_descriptor desc  = a->descriptor();
    341341        desc.append( b->descriptor() );
    342342
    343         raw_data_channel_creator result( desc, a->element_count() );
    344         for ( uint32 i = 0; i < a->element_count(); ++i )
     343        raw_data_channel_creator result( desc, a->size() );
     344        for ( uint32 i = 0; i < a->size(); ++i )
    345345        {
    346346                raw_copy_n( a->raw_data() + i * a->element_size(), a->element_size(), result.raw_data() + i*desc.element_size() );
     
    354354{
    355355        if ( a->descriptor() != b->descriptor() ) return nullptr;
    356         if ( a->element_count() % frame_count != 0 ) return nullptr;
    357         if ( b->element_count() % frame_count != 0 ) return nullptr;
     356        if ( a->size() % frame_count != 0 ) return nullptr;
     357        if ( b->size() % frame_count != 0 ) return nullptr;
    358358        size_t vtx_size = a->element_size();
    359359
    360         raw_data_channel_creator result( a->descriptor(), a->element_count() + b->element_count() );
     360        raw_data_channel_creator result( a->descriptor(), a->size() + b->size() );
    361361
    362362        if ( frame_count == 1 )
    363363        {
    364                 size_t a_size = vtx_size * a->element_count();
     364                size_t a_size = vtx_size * a->size();
    365365                raw_copy_n( a->raw_data(), a_size, result.raw_data() );
    366                 raw_copy_n( b->raw_data(), vtx_size * b->element_count(), result.raw_data() + a_size );
     366                raw_copy_n( b->raw_data(), vtx_size * b->size(), result.raw_data() + a_size );
    367367        }
    368368        else
    369369        {
    370                 size_t frame_size_a = ( a->element_count() / frame_count ) * vtx_size;
    371                 size_t frame_size_b = ( b->element_count() / frame_count ) * vtx_size;
     370                size_t frame_size_a = ( a->size() / frame_count ) * vtx_size;
     371                size_t frame_size_b = ( b->size() / frame_count ) * vtx_size;
    372372                size_t pos_a = 0;
    373373                size_t pos_b = 0;
     
    406406        int och_ti = other->get_channel_index( slot::TEXCOORD );
    407407        if ( ch_pi == -1 || ch_ti == -1 ) return;
    408         size_t size   = m_data->m_channels[ unsigned(ch_ti) ]->element_count();
    409         size_t osize  =  other->m_channels[ unsigned(och_ti) ]->element_count();
    410         size_t count  = m_data->m_channels[ unsigned(ch_pi) ]->element_count();
    411         size_t ocount =  other->m_channels[ unsigned(och_pi) ]->element_count();
     408        size_t size   = m_data->m_channels[ unsigned(ch_ti) ]->size();
     409        size_t osize  =  other->m_channels[ unsigned(och_ti) ]->size();
     410        size_t count  = m_data->m_channels[ unsigned(ch_pi) ]->size();
     411        size_t ocount =  other->m_channels[ unsigned(och_pi) ]->size();
    412412        if ( count % size != 0 || ocount % osize != 0 ) return;
    413413        if ( count / size != ocount / osize ) return;
     
    416416        {
    417417                raw_data_channel* old = m_data->m_channels[c];
    418                 bool old_is_index = old->element_count() > 0 && old->descriptor()[0].vslot == slot::INDEX;
    419                 size_t frame_count = ( old_is_index ? 1 : old->element_count() / size );
     418                bool old_is_index = old->size() > 0 && old->descriptor()[0].vslot == slot::INDEX;
     419                size_t frame_count = ( old_is_index ? 1 : old->size() / size );
    420420                m_data->m_channels[c] = append_channels( old, other->m_channels[c], frame_count );
    421421                NV_ASSERT( m_data->m_channels[c], "Merge problem!" );
     
    429429                                        raw_data_channel_creator ic( m_data->m_channels[c] );
    430430                                        uint16* indexes = reinterpret_cast<uint16*>( ic.raw_data() );
    431                                         for ( uint16 i = uint16( old->element_count() ); i < ic.size(); ++i )
     431                                        for ( uint16 i = uint16( old->size() ); i < ic.size(); ++i )
    432432                                                indexes[i] += uint16( size );
    433433
     
    438438                                        raw_data_channel_creator ic( m_data->m_channels[c] );
    439439                                        uint32* indexes = reinterpret_cast<uint32*>( ic.raw_data() );
    440                                         for ( uint32 i = old->element_count(); i < ic.size(); ++i )
     440                                        for ( uint32 i = old->size(); i < ic.size(); ++i )
    441441                                                indexes[i] += size;
    442442                                }
  • trunk/src/gfx/skeletal_mesh.cc

    r413 r415  
    1717        const raw_data_channel* pntiw_chan = a_mesh_data->get_channel<md5_vtx_pntiw>();
    1818
    19         m_pntdata.assign( pnt_chan->data_cast< md5_vtx_pnt >(), pnt_chan->element_count() );
     19        m_pntdata.assign( pnt_chan->data_cast< md5_vtx_pnt >(), pnt_chan->size() );
    2020        m_bone_offset.resize( bones->get_count() );
    2121        m_transform.resize( bones->get_count() );
     
    3434        {
    3535                const raw_data_channel* channel = channels[ch];
    36                 if ( channel->element_count() > 0 && channel != pntiw_chan )
     36                if ( channel->size() > 0 && channel != pntiw_chan )
    3737                {
    3838                        const data_descriptor& desc = channel->descriptor();
Note: See TracChangeset for help on using the changeset viewer.