Changeset 480 for trunk/src


Ignore:
Timestamp:
11/03/15 19:06:23 (10 years ago)
Author:
epyon
Message:
  • cleanup of legacy code
  • resource updates
Location:
trunk/src
Files:
5 edited

Legend:

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

    r475 r480  
    462462}
    463463
    464 mesh_data_pack* nv::assimp_loader::release_mesh_data_pack()
    465 {
    466         if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr;
    467         const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    468         bool has_bones = false;
    469         data_channel_set* meshes = data_channel_set_creator::create_set_array( m_mesh_count, 2 );
    470         for ( size_t m = 0; m < m_mesh_count; ++m )
    471         {
    472                 const aiMesh* mesh = scene->mMeshes[ m ];
    473                 data_channel_set_creator( &meshes[m] ).set_name( make_name( static_cast<const char*>( mesh->mName.data ) ) );
    474                 if ( mesh->mNumBones > 0 ) has_bones = true;
    475                 load_mesh_data(&meshes[m],m);
    476         }
    477 
    478         mesh_nodes_data* nodes = ( has_bones ? release_merged_bones( meshes ) : release_mesh_nodes_data(0) );
    479         return new mesh_data_pack( m_mesh_count, meshes, nodes );
    480 }
     464// mesh_data_pack* nv::assimp_loader::release_mesh_data_pack()
     465// {
     466//      if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr;
     467//      const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
     468//      bool has_bones = false;
     469//      data_channel_set* meshes = data_channel_set_creator::create_set_array( m_mesh_count, 2 );
     470//      for ( size_t m = 0; m < m_mesh_count; ++m )
     471//      {
     472//              const aiMesh* mesh = scene->mMeshes[ m ];
     473//              data_channel_set_creator( &meshes[m] ).set_name( make_name( static_cast<const char*>( mesh->mName.data ) ) );
     474//              if ( mesh->mNumBones > 0 ) has_bones = true;
     475//              load_mesh_data(&meshes[m],m);
     476//      }
     477//
     478//      mesh_nodes_data* nodes = ( has_bones ? release_merged_bones( meshes ) : release_mesh_nodes_data(0) );
     479//      return new mesh_data_pack( m_mesh_count, meshes, nodes );
     480// }
    481481
    482482nv::size_t nv::assimp_loader::get_nodes_data_count() const
  • trunk/src/formats/nmd_loader.cc

    r475 r480  
    5050}
    5151
    52 mesh_data_pack* nv::nmd_loader::release_mesh_data_pack()
    53 {
    54         uint32 size = m_meshes.size();
    55         data_channel_set* meshes = data_channel_set_creator::create_set_array( size, 0 );
    56         for ( uint32 i = 0; i < size; ++i )
    57         {
    58                 meshes[i] = move( *m_meshes[i] );
    59                 delete m_meshes[i];
    60         }
    61         m_meshes.clear();
    62         return new mesh_data_pack( size, meshes, release_mesh_nodes_data() );
    63 }
    64 
    6552void nv::nmd_loader::reset()
    6653{
     
    240227}
    241228
    242 void nv::nmd_dump( stream& stream_out, const mesh_data_pack* model, const string_table* strings, uint64 name )
     229void nv::nmd_dump( stream& stream_out, array_view< data_channel_set* > meshes, const mesh_nodes_data* nodes, const string_table* strings /*= nullptr*/, uint64 name /*= 0 */ )
    243230{
    244231        uint32 elements = ( strings ? 1 : 0 ) // +1 string array
    245                 + model->get_count() // meshes
    246                 + ( model->get_node_count() > 0 ? 1 : 0 ); // nodes
     232                + meshes.size() // meshes
     233                + ( nodes && nodes->size() > 0 ? 1 : 0 ); // nodes
    247234        nmd_dump_header( stream_out, elements, name );
    248235
    249         for ( uint32 i = 0; i < model->get_count(); ++i )
    250         {
    251                 nmd_dump_element( stream_out, *model->get_mesh( i ), nv::nmd_type::MESH );
    252         }
    253 
    254         if ( model->get_node_count() > 0 )
    255         {
    256                 nmd_dump_nodes( stream_out, *model->get_nodes() );
     236        for ( uint32 i = 0; i < meshes.size(); ++i )
     237        {
     238                NV_ASSERT( meshes[i], "mesh is null!" );
     239                nmd_dump_element( stream_out, *meshes[i], nv::nmd_type::MESH );
     240        }
     241
     242        if ( nodes && nodes->size() > 0 )
     243        {
     244                nmd_dump_nodes( stream_out, *nodes );
    257245        }
    258246
     
    262250        }
    263251}
     252
     253void nv::nmd_dump( stream& stream_out, const mesh_nodes_data& animation, const string_table* strings, uint64 name )
     254{
     255        uint32 elements = ( strings ? 1 : 0 ) // +1 string array
     256                + ( animation.size() > 0 ? 1 : 0 ); // nodes
     257        nmd_dump_header( stream_out, elements, name );
     258
     259        if ( animation.size() > 0 )
     260        {
     261                nmd_dump_nodes( stream_out, animation );
     262        }
     263
     264        if ( strings )
     265        {
     266                nmd_dump_strings( stream_out, *strings );
     267        }
     268}
  • trunk/src/formats/obj_loader.cc

    r454 r480  
    357357}
    358358
    359 mesh_data_pack* nv::obj_loader::release_mesh_data_pack()
    360 {
    361         uint32 size = m_meshes.size();
    362         data_channel_set* meshes = data_channel_set_creator::create_set_array( size, 1 );
    363         for ( uint32 i = 0; i < size; ++i )
    364         {
    365                 meshes[i] = move( *m_meshes[i] );
    366                 delete m_meshes[i];
    367         }
    368         m_meshes.clear();
    369         return new mesh_data_pack( size, meshes );
    370 }
  • trunk/src/gfx/mesh_creator.cc

    r471 r480  
    157157                }
    158158        }
    159 }
    160 
    161 nv::mesh_data_creator::mesh_data_creator( data_channel_set* data ) : m_data( data )
    162 {
    163         initialize();
    164159}
    165160
     
    656651}
    657652
    658 void nv::mesh_creator::delete_mesh( uint32 index )
    659 {
    660         if ( index < m_pack->get_count() )
    661         {
    662 
    663                 m_pack->m_meshes[index] = move( m_pack->m_meshes[m_pack->m_count - 1] );
    664                 m_pack->m_count--;
    665         }
    666 }
  • trunk/src/gfx/skeleton_instance.cc

    r477 r480  
    66
    77#include "nv/gfx/skeleton_instance.hh"
     8
     9#include "nv/core/profiler.hh"
    810
    911void nv::skeleton_binding::prepare( const mesh_nodes_data* node_data, const mesh_nodes_data* bone_data )
     
    6264                        for ( uint32 n = 0; n < node_data->size(); ++n )
    6365                                if ( ( *node_data )[n]->get_parent_id() == -1 )
    64                                         animate_rec( node_data, binding, frame, n, mat4() );
     66                                        animate_rec( node_data, binding, frame, n, transform() );
    6567                }
    6668        }
    6769}
    6870
    69 void nv::skeleton_instance::animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const mat4& parent )
     71void nv::skeleton_instance::animate_rec( const mesh_nodes_data* node_data, const skeleton_binding& binding, float frame, uint32 id, const transform& parent )
    7072{
    7173        // TODO: fix transforms, which are now embedded,
    7274        //       see note in assimp_loader.cc:load_node
    7375        const data_channel_set* node = ( *node_data )[id];
    74         mat4 node_mat( node->get_transform() );
     76        transform node_mat( node->get_transform() );
    7577
    7678        if ( node->size() > 0 )
    7779        {
    7880                raw_channel_interpolator interpolator( node, binding.m_key );
    79                 node_mat = interpolator.get< mat4 >( frame );
     81                node_mat = interpolator.get< transform >( frame );
    8082        }
    8183
    82         mat4 global_mat = parent * node_mat;
     84        transform global_mat = parent * node_mat;
    8385
    8486        sint16 bone_id = binding.m_indices[id];
    8587        if ( bone_id >= 0 )
    8688        {
    87                 m_transform[bone_id] = global_mat * binding.m_offsets[bone_id];
     89                m_transform[bone_id] = global_mat.extract() * binding.m_offsets[bone_id];
    8890        }
    8991
Note: See TracChangeset for help on using the changeset viewer.