Ignore:
Timestamp:
07/10/15 14:16:42 (10 years ago)
Author:
epyon
Message:
  • mesh_data and key_data are data_channel_set (WIP)
  • massive cleanup of privacy in data_channels
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/formats/nmd_loader.cc

    r415 r416  
    88#include "nv/io/std_stream.hh"
    99#include "nv/stl/string.hh"
     10#include "nv/interface/data_channel_access.hh"
    1011
    1112using namespace nv;
     
    3435bool nv::nmd_loader::load_mesh( stream& source, const nmd_element_header& e )
    3536{
    36         mesh_data* mesh = new mesh_data();
     37        data_channel_set_creator mesh;
    3738        for ( uint32 s = 0; s < e.children; ++s )
    3839        {
     
    4546                raw_data_channel_creator channel_creator( stream_header.format, stream_header.count );
    4647                source.read( channel_creator.raw_data(), channel_creator.element_size(), channel_creator.size() );
    47                 mesh->add_channel( channel_creator.release() );
     48                mesh.add_channel( channel_creator.release() );
    4849        }
    4950        m_mesh_names.push_back( e.name );
    50         m_meshes.push_back( mesh );
    51         return true;
    52 }
    53 
    54 mesh_data* nv::nmd_loader::release_mesh_data( size_t index )
    55 {
    56         mesh_data* result = m_meshes[ index ];
    57         if ( m_strings ) result->set_name( m_strings->get( m_mesh_names[ index ] ) );
     51        m_meshes.push_back( mesh.release() );
     52        return true;
     53}
     54
     55data_channel_set* nv::nmd_loader::release_mesh_data( size_t index )
     56{
     57        data_channel_set* result = m_meshes[ index ];
     58        if ( m_strings ) data_channel_set_creator( result ).set_name( m_strings->get( m_mesh_names[ index ] ) );
    5859        m_meshes[ index ] = nullptr;
    5960        return result;
     
    6364{
    6465        uint32 size = m_meshes.size();
    65         mesh_data* meshes = new mesh_data[ size ];
     66        data_channel_set* meshes = data_channel_set_creator::create_array( size, 0 );
    6667        for ( uint32 i = 0; i < size; ++i )
    6768        {
    68                 m_meshes[i]->move_to( meshes[i] );
     69                data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] );
    6970                delete m_meshes[i];
    7071        }
     
    130131                                raw_data_channel_creator channel_creator( cheader.format, cheader.count );
    131132                                source.read( channel_creator.raw_data(), channel_creator.element_size(), channel_creator.size() );
    132                                 kdata->add_channel( channel_creator.release() );
     133                                kdata->add_key_channel( channel_creator.release() );
    133134                        }
    134135                }
     
    160161// nmd format dump
    161162// HACK : TEMPORARY - will go to it's own file, probably nmd_io
    162 static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out )
    163 {
    164         array_view< raw_data_channel* > data  = mesh->get_raw_channels();
    165 
     163static void nmd_dump_mesh( const data_channel_set* mesh, stream& stream_out )
     164{
    166165        uint32 size = sizeof( nmd_element_header );
    167         for ( auto chan : data )
     166        for ( auto chan : *mesh )
    168167        {
    169168                size += sizeof( nmd_element_header ) + sizeof( nmd_stream_header );
     
    174173        eheader.type     = nmd_type::MESH;
    175174        eheader.name     = 0;
    176         eheader.children = static_cast< uint16 >( data.size() );
     175        eheader.children = static_cast< uint16 >( mesh->size() );
    177176        eheader.size     = size;
    178177        stream_out.write( &eheader, sizeof( eheader ), 1 );
    179178
    180         for ( auto chan : data )
     179        for ( auto chan : *mesh )
    181180        {
    182181                nmd_element_header cheader;
     
    203202                total += sizeof( nmd_element_header ) + sizeof( nmd_node_header );
    204203                if ( node->data )
    205                         for ( uint32 c = 0; c < node->data->get_channel_count(); ++c )
     204                        for ( uint32 c = 0; c < node->data->size(); ++c )
    206205                        {
    207206                                total += sizeof( nmd_element_header ) + sizeof( nmd_stream_header );
     
    227226                const mesh_node_data* node = nodes->get_node(i);
    228227                uint32 chan_size  = 0;
    229                 uint32 chan_count = ( node->data ? node->data->get_channel_count() : 0 );
     228                uint32 chan_count = ( node->data ? node->data->size() : 0 );
    230229                for ( uint32 c = 0; c < chan_count; ++c )
    231230                {
     
    280279        for ( uint32 i = 0; i < model->get_count(); ++i )
    281280        {
    282                 const mesh_data* mesh = model->get_mesh(i);
     281                const data_channel_set* mesh = model->get_mesh(i);
    283282                nmd_dump_mesh( mesh, stream_out );
    284283        }
Note: See TracChangeset for help on using the changeset viewer.