Changeset 281


Ignore:
Timestamp:
07/08/14 21:49:37 (11 years ago)
Author:
epyon
Message:
  • animation key raw sizes (the whole system will be dumped though)
  • bugfix for string_table
  • nv::slot is now an enum class
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gfx/animation.hh

    r249 r281  
    4949                        return interpolate( m_keys[index].value, m_keys[index + 1].value, factor );
    5050                }
    51                 virtual void dump( stream* out_stream )
     51                virtual uint32 raw_size() const
     52                {
     53                        return sizeof( size_t ) + m_keys.size() * sizeof( key );
     54                }
     55                virtual void dump( stream* out_stream ) const
    5256                {
    5357                        size_t sz = m_keys.size();
     
    7781                virtual mat4 get_matrix( float time ) const = 0;
    7882                virtual transform get_transform( float time ) const = 0;
    79                 virtual void dump( stream* out_stream ) = 0;
     83                virtual void dump( stream* out_stream ) const = 0;
    8084                virtual void load( stream* in_stream ) = 0;
    8185                virtual bool empty() const = 0;
     86                virtual uint32 raw_size() const = 0;
    8287                virtual ~key_animation_data() {}
    8388        };
     
    111116                        return result;
    112117                }
    113                 virtual void dump( stream* out_stream )
     118                virtual uint32 raw_size() const
     119                {
     120                        return m_positions.raw_size() + m_rotations.raw_size() + m_scales.raw_size();
     121                }
     122                virtual void dump( stream* out_stream ) const
    114123                {
    115124                        m_positions.dump( out_stream );
     
    140149                const transform* data() const { return m_keys.data(); }
    141150
    142                 virtual void dump( stream* out_stream )
     151                virtual uint32 raw_size() const
     152                {
     153                        return sizeof( size_t ) + m_keys.size() * sizeof( transform );
     154                }
     155
     156                virtual void dump( stream* out_stream ) const
    143157                {
    144158                        size_t sz = m_keys.size();
  • trunk/nv/interface/mesh_data.hh

    r280 r281  
    3232                }
    3333
    34                 bool is_index() const { return count > 0 && desc.slots[0].vslot == INDEX; }
     34                bool is_index() const { return count > 0 && desc.slots[0].vslot == slot::INDEX; }
    3535
    3636                uint32 size() const { return count * desc.size; }
  • trunk/nv/interface/vertex.hh

    r280 r281  
    1616{
    1717
    18         enum slot
     18        enum class slot : uint8
    1919        {
    2020                POSITION       = 0,
     
    3131        };
    3232
    33 //      struct vertex_descriptor
    34 //      {
    35 //              static const datatype position_etype   = NONE;
    36 //              static const datatype normal_etype     = NONE;
    37 //              static const datatype texcoord_etype   = NONE;
    38 //              static const datatype tangent_etype    = NONE;
    39 //              static const datatype boneindex_etype  = NONE;
    40 //              static const datatype boneweight_etype = NONE;
    41 //              static const datatype color_etype      = NONE;
    42 //      };
    43 //
    44 //      template < typename VD >
    45 //      struct vertex_type
    46 //              : public VD
    47 //
    48 //      {
    49 //              typedef typename enum_to_type< VD::position_etype >::type    position_type;
    50 //              typedef typename enum_to_type< VD::normal_etype >::type      normal_type;
    51 //              typedef typename enum_to_type< VD::texcoord_etype >::type    texcoord_type;
    52 //              typedef typename enum_to_type< VD::tangent_etype >::type     tangent_type;
    53 //              typedef typename enum_to_type< VD::boneindex_etype >::type   boneindex_type;
    54 //              typedef typename enum_to_type< VD::boneweight_etype >::type  boneweight_type;
    55 //              typedef typename enum_to_type< VD::color_etype >::type       color_type;
    56 //      };
     33        enum animation_slot
     34        {
     35//              TIME     = 0,
     36//              POSITION = 1,
     37//              ROTATION = 2,
     38//              SCALE    = 3,
     39//              MATRIX   = 4,
     40//              ANIM_SLOT_MAX       = 4,
     41//              ANIM_SLOT_MAX_STORE = 5,
     42        };
    5743
    5844        namespace detail
     
    6652
    6753                template < typename VT >
    68                 struct vertex_has_slot_impl< VT, POSITION >
     54                struct vertex_has_slot_impl< VT, slot::POSITION >
    6955                {
    7056                private:
     
    7965
    8066                template < typename VT >
    81                 struct vertex_has_slot_impl< VT, NORMAL >
     67                struct vertex_has_slot_impl< VT, slot::NORMAL >
    8268                {
    8369                private:
     
    9278
    9379                template < typename VT >
    94                 struct vertex_has_slot_impl< VT, TEXCOORD >
     80                struct vertex_has_slot_impl< VT, slot::TEXCOORD >
    9581                {
    9682                private:
     
    10591
    10692                template < typename VT >
    107                 struct vertex_has_slot_impl< VT, TANGENT >
     93                struct vertex_has_slot_impl< VT, slot::TANGENT >
    10894                {
    10995                private:
     
    118104
    119105                template < typename VT >
    120                 struct vertex_has_slot_impl< VT, BONEINDEX >
     106                struct vertex_has_slot_impl< VT, slot::BONEINDEX >
    121107                {
    122108                private:
     
    131117
    132118                template < typename VT >
    133                 struct vertex_has_slot_impl< VT, BONEWEIGHT >
     119                struct vertex_has_slot_impl< VT, slot::BONEWEIGHT >
    134120                {
    135121                private:
     
    144130
    145131                template < typename VT >
    146                 struct vertex_has_slot_impl< VT, COLOR >
     132                struct vertex_has_slot_impl< VT, slot::COLOR >
    147133                {
    148134                private:
     
    170156
    171157                template < typename VT >
    172                 struct vertex_slot_info_impl< VT, POSITION, true >
     158                struct vertex_slot_info_impl< VT, slot::POSITION, true >
    173159                {
    174160                        typedef decltype( VT::position ) value_type;
     
    178164
    179165                template < typename VT >
    180                 struct vertex_slot_info_impl< VT, TEXCOORD, true >
     166                struct vertex_slot_info_impl< VT, slot::TEXCOORD, true >
    181167                {
    182168                        typedef decltype( VT::texcoord ) value_type;
     
    186172
    187173                template < typename VT >
    188                 struct vertex_slot_info_impl< VT, NORMAL, true >
     174                struct vertex_slot_info_impl< VT, slot::NORMAL, true >
    189175                {
    190176                        typedef decltype( VT::normal ) value_type;
     
    194180
    195181                template < typename VT >
    196                 struct vertex_slot_info_impl< VT, TANGENT, true >
     182                struct vertex_slot_info_impl< VT, slot::TANGENT, true >
    197183                {
    198184                        typedef decltype( VT::tangent ) value_type;
     
    202188
    203189                template < typename VT >
    204                 struct vertex_slot_info_impl< VT, BONEINDEX, true >
     190                struct vertex_slot_info_impl< VT, slot::BONEINDEX, true >
    205191                {
    206192                        typedef decltype( VT::boneindex ) value_type;
     
    210196
    211197                template < typename VT >
    212                 struct vertex_slot_info_impl< VT, BONEWEIGHT, true >
     198                struct vertex_slot_info_impl< VT, slot::BONEWEIGHT, true >
    213199                {
    214200                        typedef decltype( VT::boneweight ) value_type;
     
    218204
    219205                template < typename VT >
    220                 struct vertex_slot_info_impl< VT, COLOR, true >
     206                struct vertex_slot_info_impl< VT, slot::COLOR, true >
    221207                {
    222208                        typedef decltype( VT::color ) value_type;
     
    224210                        static const int      offset = offsetof( VT, color );
    225211                };
    226        
     212
     213                template < typename KEY, animation_slot SLOT >
     214                struct key_has_slot_impl
     215                {
     216                        static bool const value = false;
     217                };
     218
    227219        }
    228220
     
    243235                uint32   offset;
    244236                slot     vslot;
     237                vertex_descriptor_slot() : etype(NONE), offset(0), vslot(slot::POSITION) {}
    245238        };
    246239
    247240        struct vertex_descriptor
    248241        {
    249                 vertex_descriptor_slot slots[ SLOT_MAX_STORE ];
     242                vertex_descriptor_slot slots[ slot::SLOT_MAX_STORE ];
    250243                uint32                 count;
    251244                uint32                 size;
     245
     246                vertex_descriptor() : count(0), size(0) {}
    252247
    253248                template < typename IDX >
  • trunk/nv/interface/vertex_buffer.hh

    r256 r281  
    100100                        m_map[ location ] = p;
    101101                }
     102                void add_vertex_buffer( slot location, vertex_buffer* buffer, datatype datatype, size_t components, size_t offset = 0, size_t stride = 0, bool owner = true )
     103                {
     104                        add_vertex_buffer( (int)location, buffer, datatype, components, offset, stride, owner );
     105                }
    102106
    103107                void add_vertex_buffers( vertex_buffer* buffer, const mesh_raw_channel* channel )
     
    131135                        }
    132136                }
     137                void update_vertex_buffer( slot location, vertex_buffer* b, bool owner )
     138                {update_vertex_buffer( (int)location, b, owner ); }
     139                void update_vertex_buffer( slot location, size_t offset ) {update_vertex_buffer( (int)location, offset );       }
    133140                void set_index_buffer( index_buffer* buffer, datatype datatype, bool owner )
    134141                {
     
    152159                        return nullptr;
    153160                }
     161                vertex_buffer* find_buffer( slot location ) { return find_buffer((int)location); }
    154162                bool has_index_buffer() const { return m_index != nullptr; }
    155163                datatype get_index_buffer_type() const { return m_index_type; }
  • trunk/nv/io/string_table.hh

    r280 r281  
    6060                        in->read( &m_size, sizeof( m_size ), 1 );
    6161                        m_offsets = new offset[ m_count ];
    62                         m_data    = new char[ m_count ];
     62                        m_data    = new char[ m_size ];
    6363                        in->read( m_offsets, sizeof( offset ), m_count );
    6464                        in->read( m_data,    sizeof( char ), m_size );
     
    8080                index insert( const std::string& s );
    8181                string_table* create_table() const;
     82                uint32 dump_size() const;
    8283                void dump( nv::stream* out ) const;
    8384                const char* get( index i ) const;
  • trunk/src/gfx/keyframed_mesh.cc

    r280 r281  
    139139        m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location();
    140140        m_loc_next_normal   = a_program->get_attribute( "nv_next_normal" )->get_location();
    141         m_va = a_device->create_vertex_array( a_data, nv::STATIC_DRAW );
    142         vertex_buffer* vb = m_va->find_buffer( nv::POSITION );
    143         m_va->add_vertex_buffer( m_loc_next_position, vb, nv::FLOAT, 3, 0,              sizeof( vertex_pn ), false );
    144         m_va->add_vertex_buffer( m_loc_next_normal,   vb, nv::FLOAT, 3, sizeof( vec3 ), sizeof( vertex_pn ), false );
     141        m_va = a_device->create_vertex_array( a_data, STATIC_DRAW );
     142        vertex_buffer* vb = m_va->find_buffer( slot::POSITION );
     143        m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0,              sizeof( vertex_pn ), false );
     144        m_va->add_vertex_buffer( m_loc_next_normal,   vb, FLOAT, 3, sizeof( vec3 ), sizeof( vertex_pn ), false );
    145145}
    146146
  • trunk/src/gfx/skeletal_mesh.cc

    r275 r281  
    4343                m_animation->update_skeleton( m_transform.data(), (float)m_animation_time * 0.001f );
    4444                m_mesh_data->apply( m_transform.data() );
    45                 vertex_buffer* vb = m_va->find_buffer( nv::POSITION );
     45                vertex_buffer* vb = m_va->find_buffer( nv::slot::POSITION );
    4646                vb->bind();
    4747                vb->update( m_mesh_data->data(), 0, m_mesh_data->size() );
  • trunk/src/gui/gui_renderer.cc

    r268 r281  
    268268        {
    269269                nv::vertex_buffer* vb = (nv::vertex_buffer*)sr->buffer.get_buffer();
    270                 sr->varray->update_vertex_buffer( nv::POSITION, vb, false );
    271                 sr->varray->update_vertex_buffer( nv::TEXCOORD, vb, false );
    272                 sr->varray->update_vertex_buffer( nv::COLOR,    vb, false );
     270                sr->varray->update_vertex_buffer( nv::slot::POSITION, vb, false );
     271                sr->varray->update_vertex_buffer( nv::slot::TEXCOORD, vb, false );
     272                sr->varray->update_vertex_buffer( nv::slot::COLOR,    vb, false );
    273273        }
    274274        sr->texture->bind( nv::TEX_DIFFUSE );
  • trunk/src/io/string_table.cc

    r280 r281  
    7070}
    7171
     72nv::uint32 nv::string_table_creator::dump_size() const
     73{
     74        return sizeof( index ) + sizeof( uint32 ) +
     75                sizeof( offset ) * m_offsets.size() +
     76                sizeof( char ) * m_data.size();
     77}
     78
Note: See TracChangeset for help on using the changeset viewer.