Changeset 425
- Timestamp:
- 07/17/15 13:34:28 (10 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/formats/assimp_loader.hh
r422 r425 20 20 { 21 21 public: 22 explicit assimp_loader( const std::string& a_ext, uint32 a_assimp_flags = 0 );22 explicit assimp_loader( string_table* strings, const string_view& a_ext, uint32 a_assimp_flags = 0 ); 23 23 virtual bool load( stream& source ); 24 24 virtual data_channel_set* release_mesh_data( size_t index = 0 ); … … 37 37 void create_keys( mesh_node_data* data, const void* vnode ); 38 38 39 string_table* m_strings; 40 std::string m_ext; 39 const_string m_ext; 41 40 uint32 m_assimp_flags; 42 41 const void* m_scene; -
trunk/nv/formats/md2_loader.hh
r416 r425 24 24 { 25 25 public: 26 md2_loader();26 explicit md2_loader( string_table* strings ); 27 27 virtual ~md2_loader(); 28 28 virtual bool load( stream& source ); … … 36 36 private: 37 37 void* m_md2; 38 string_table* m_strings; 38 39 vector< uint16 > m_new_indexes; 39 40 vector< uint16 > m_new_vindexes; -
trunk/nv/formats/md3_loader.hh
r417 r425 30 30 { 31 31 public: 32 md3_loader(bool merge_all = true );32 explicit md3_loader( string_table* strings, bool merge_all = true ); 33 33 virtual ~md3_loader(); 34 34 virtual bool load( stream& source ); -
trunk/nv/formats/md5_loader.hh
r416 r425 52 52 enum file_type { UNKNOWN, MESH, ANIMATION }; 53 53 54 md5_loader() :m_type( UNKNOWN ), m_nodes( nullptr ) {}54 explicit md5_loader( string_table* strings ) : mesh_loader( strings ), m_type( UNKNOWN ), m_nodes( nullptr ) {} 55 55 virtual ~md5_loader(); 56 56 virtual bool load( stream& source ); -
trunk/nv/formats/nmd_loader.hh
r423 r425 78 78 { 79 79 public: 80 nmd_loader() : m_node_data( nullptr ), m_node_array( nullptr ), m_strings( nullptr ) {}80 explicit nmd_loader( string_table* strings ) : mesh_loader( strings ), m_node_data( nullptr ), m_node_array( nullptr ) {} 81 81 virtual bool load( stream& source ); 82 82 virtual data_channel_set* release_mesh_data( size_t index = 0 ); … … 98 98 mesh_nodes_data* m_node_data; 99 99 mesh_node_data* m_node_array; 100 string_table* m_strings;101 100 // vector< uint16 > m_mesh_names; 102 101 // vector< uint16 > m_node_names; -
trunk/nv/formats/obj_loader.hh
r416 r425 25 25 { 26 26 public: 27 obj_loader( bool normals = true, bool tangents = false );27 obj_loader( string_table* strings, bool normals = true, bool tangents = false ); 28 28 virtual bool load( stream& source ); 29 29 virtual data_channel_set* release_mesh_data( size_t index = 0 ); … … 32 32 ~obj_loader(); 33 33 private: 34 data_descriptor m_descriptor;35 34 bool m_normals; 36 35 bool m_tangents; 36 data_descriptor m_descriptor; 37 37 vector< data_channel_set* > m_meshes; 38 38 }; -
trunk/nv/interface/data_channel_access.hh
r424 r425 141 141 const_iterator end() const { return m_set->end(); } 142 142 143 void set_name( const char* /*name*/ ) {}// { m_name = name; }144 //const std::string& get_name() const { return m_name; }145 146 143 void move_to( data_channel_set& other ) 147 144 { -
trunk/nv/interface/mesh_loader.hh
r423 r425 20 20 #include <nv/interface/mesh_data.hh> 21 21 #include <nv/stl/stream.hh> 22 #include <nv/io/string_table.hh> 22 23 23 24 namespace nv … … 27 28 { 28 29 public: 29 mesh_loader() {}30 explicit mesh_loader( string_table* strings ) : m_strings( strings ) {} 30 31 virtual ~mesh_loader() {} 31 32 virtual bool load( stream& source ) = 0; … … 35 36 virtual size_t get_nodes_data_count() const { return 0; } 36 37 virtual mesh_nodes_data* release_mesh_nodes_data( size_t = 0 ) { return nullptr; } 38 protected: 39 inline uint64 make_name( const string_view& name ) 40 { 41 return m_strings ? m_strings->insert( name ) : name.get_hash< uint64 >(); 42 } 43 string_table* m_strings; 37 44 }; 38 45 -
trunk/nv/io/string_table.hh
r422 r425 62 62 } 63 63 64 uint32 size() const { return m_map.size(); } 65 bool empty() const { return m_map.empty(); } 64 66 uint32 dump_size() const; 65 67 void dump( stream& out ) const; -
trunk/src/formats/assimp_loader.cc
r424 r425 57 57 58 58 59 nv::assimp_loader::assimp_loader( const std::string& a_ext, uint32 a_assimp_flags /*= 0 */ )60 : m _scene( nullptr ), m_mesh_count(0)59 nv::assimp_loader::assimp_loader( string_table* strings, const string_view& a_ext, uint32 a_assimp_flags /*= 0 */ ) 60 : mesh_loader( strings ), m_scene( nullptr ), m_mesh_count(0) 61 61 { 62 62 m_ext = a_ext; … … 92 92 char* data = new char[ size ]; 93 93 source.read( data, size, 1 ); 94 const aiScene* scene = aiImportFileFromMemory( data, size, m_assimp_flags, m_ext. c_str() );94 const aiScene* scene = aiImportFileFromMemory( data, size, m_assimp_flags, m_ext.data() ); 95 95 96 96 if( !scene) … … 125 125 desc.initialize< assimp_plain_vtx >(); 126 126 data_channel_set_creator maccess( data ); 127 maccess.set_name( mesh->mName.data ); 127 const char* name = mesh->mName.data; 128 maccess.set_name( make_name( name ) ); 128 129 uint8* cdata = maccess.add_channel( desc, mesh->mNumVertices ).raw_data(); 129 130 uint16* indices = reinterpret_cast<uint16*>( maccess.add_channel< index_u16 >( mesh->mNumFaces * 3 ).raw_data() ); … … 201 202 bones[m].data = data_channel_set_creator::create_set( 0 ); 202 203 data_channel_set_creator access( bones[m].data ); 203 access.set_name( hash_string< uint64 >( bone->mName.data ) ); 204 const char* name = bone->mName.data; 205 access.set_name( make_name( name ) ); 204 206 access.set_transform( offset ); 205 207 } … … 334 336 mesh_node_data* bones = new mesh_node_data[ final_bones.size() ]; 335 337 raw_copy( final_bones.begin(), final_bones.end(), bones ); 336 int name_; 337 return new mesh_nodes_data( /*"bones"*/0, final_bones.size(), bones ); 338 return new mesh_nodes_data( make_name( "bones" ), final_bones.size(), bones ); 338 339 } 339 340 … … 356 357 load_node( index, data, root, 0, -1 ); 357 358 358 int name; 359 return new mesh_nodes_data( /*anim->mName.data*/0, count, data, frame_rate, duration, flat ); 359 return new mesh_nodes_data( make_name( static_cast<const char*>( anim->mName.data ) ), count, data, frame_rate, duration, flat ); 360 360 } 361 361 … … 375 375 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 376 376 const aiNode* node = reinterpret_cast<const aiNode*>( vnode ); 377 st d::string name( node->mName.data);377 string_view name( static_cast< const char* >( node->mName.data ) ); 378 378 const aiAnimation* anim = scene->mAnimations[anim_id]; 379 379 const aiNodeAnim* anode = nullptr; … … 382 382 { 383 383 anode = anim->mChannels[i]; 384 if ( st d::string( anode->mNodeName.data) == name ) break;384 if ( string_view( static_cast< const char* >( anode->mNodeName.data ) ) == name ) break; 385 385 anode = nullptr; 386 386 } … … 394 394 395 395 data_channel_set_creator access( a_data.data ); 396 access.set_name( hash_string< uint64 >( name.c_str()) );396 access.set_name( make_name( name ) ); 397 397 access.set_parent_id( parent_id ); 398 398 // This value is ignored by the create_transformed_keys, but needed by create_direct_keys! … … 468 468 { 469 469 const aiMesh* mesh = scene->mMeshes[ m ]; 470 data_channel_set_creator( &meshes[m] ).set_name( m esh->mName.data);470 data_channel_set_creator( &meshes[m] ).set_name( make_name( static_cast<const char*>( mesh->mName.data ) ) ); 471 471 if ( mesh->mNumBones > 0 ) has_bones = true; 472 472 load_mesh_data(&meshes[m],m); -
trunk/src/formats/md2_loader.cc
r424 r425 199 199 static bool s_md2_normal_ready = false; 200 200 201 md2_loader::md2_loader() : m_md2( nullptr ) 201 md2_loader::md2_loader( string_table* strings ) 202 : mesh_loader( strings ), m_md2( nullptr ) 202 203 { 203 204 if ( !s_md2_normal_ready ) … … 331 332 uint16* icp = &maccess.add_channel< index_u16 >( m_new_indexes.size() ).data()->index; 332 333 334 maccess.set_name( make_name( "md2_mesh" ) ); 335 333 336 uint32 index = 0; 334 337 while ( frame_count > 0 ) -
trunk/src/formats/md3_loader.cc
r424 r425 235 235 static bool s_normal_ready = false; 236 236 237 md3_loader::md3_loader( bool merge_all )238 : m _merge_all( merge_all ), m_md3( nullptr )237 md3_loader::md3_loader( string_table* strings, bool merge_all ) 238 : mesh_loader( strings ), m_merge_all( merge_all ), m_md3( nullptr ) 239 239 { 240 240 if ( !s_normal_ready ) … … 353 353 354 354 data_channel_set_creator maccess( data ); 355 maccess.set_name( reinterpret_cast<char*>( md3->header.name ) ); 355 maccess.set_name( make_name( reinterpret_cast<char*>( md3->header.name ) ) ); 356 356 357 357 358 vtx_md3_pn* vtx_pn = maccess.add_channel< vtx_md3_pn >( static_cast< uint32 >( num_verts * frame_count ) ).data(); … … 426 427 nodes[i].data = data_channel_set_creator::create_set( 1 ); 427 428 data_channel_set_creator access( nodes[i].data ); 428 access.set_name( hash_string< uint64 >( name.data()) );429 access.set_name( make_name( name ) ); 429 430 load_tags( access.add_channel<md3_key>( uint32( md3->header.num_frames ) ).channel(), name ); 430 431 } 431 int name_; 432 return new mesh_nodes_data( 0,/*"tags"*/ node_count, nodes ); 432 return new mesh_nodes_data( m_strings ? m_strings->insert( "tags" ) : 0, node_count, nodes ); 433 433 } 434 434 … … 442 442 data = data_channel_set_creator::create_set_array(1,3); 443 443 release_mesh_frame( &data[0], -1, -1 ); 444 data_channel_set_creator( &data[0] ).set_name( reinterpret_cast< char* >( md3->header.name ) );445 444 } 446 445 else … … 451 450 { 452 451 release_mesh_frame( &data[i], -1, i ); 453 data_channel_set_creator( &data[i] ).set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name) );452 data_channel_set_creator( &data[i] ).set_name( make_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) ) ); 454 453 } 455 454 } -
trunk/src/formats/md5_loader.cc
r424 r425 112 112 assert( m_nodes == nullptr ); 113 113 nodes = new mesh_node_data[ num_joints ]; 114 int name_; //"md5_bones" 115 m_nodes = new mesh_nodes_data( 0, num_joints, nodes ); 114 m_nodes = new mesh_nodes_data( make_name( "md5_bones"), num_joints, nodes ); 116 115 discard( sstream, "{" ); 117 116 for ( size_t i = 0; i < m_nodes->get_count(); ++i ) … … 133 132 access.set_parent_id( parent_id ); 134 133 access.set_transform( transform( pos, orient ).inverse().extract() ); 135 access.set_name( hash_string< uint64 >( name.c_str() ) );134 access.set_name( make_name( name.c_str() ) ); 136 135 next_line( sstream ); 137 136 } … … 157 156 sstream >> shader; 158 157 remove_quotes( shader ); 158 maccess.set_name( make_name( shader ) ); 159 159 next_line( sstream ); 160 160 } … … 243 243 assert( nodes == nullptr ); 244 244 nodes = new mesh_node_data[ num_joints ]; 245 int name_; 246 m_nodes = new mesh_nodes_data( 0/*"md5_animation"*/, num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 245 m_nodes = new mesh_nodes_data( make_name( "md5_animation" ), num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 247 246 joint_infos.resize( num_joints ); 248 247 … … 257 256 data_channel_set_creator access( nodes[i].data ); 258 257 access.add_channel< md5_key_t >( num_frames ); 259 access.set_name( hash_string< uint64 >( name.c_str() ) );258 access.set_name( make_name( name.c_str() ) ); 260 259 access.set_parent_id( parent_id ); 261 260 next_line( sstream ); -
trunk/src/formats/nmd_loader.cc
r424 r425 47 47 { 48 48 data_channel_set* result = m_meshes[ index ]; 49 // if ( m_strings ) data_channel_set_creator( result ).set_name( m_strings->get( m_mesh_names[ index ] ) );50 49 m_meshes[ index ] = nullptr; 51 50 return result; … … 68 67 { 69 68 for ( auto mesh : m_meshes ) if ( mesh ) delete mesh; 70 if ( m_strings ) delete m_strings;71 69 if ( m_node_data ) delete m_node_data; 72 70 m_meshes.clear(); 73 // m_mesh_names.clear();74 // m_node_names.clear();75 71 76 72 m_node_data = nullptr; 77 73 m_node_array = nullptr; 78 m_strings = nullptr;79 74 } 80 75 … … 92 87 bool nv::nmd_loader::load_strings( stream& source ) 93 88 { 94 NV_ASSERT( m_strings == nullptr, "MULTIPLE STRING ENTRIES!" );89 if ( !m_strings ) return true; 95 90 // TODO: load strings optionally 96 m_strings = new string_table( source ); 91 string_table* strings = new string_table( source ); 92 m_strings->insert( strings ); 93 delete strings; 97 94 return true; 98 95 } … … 110 107 skip_attributes( source, element_header.attributes ); 111 108 NV_ASSERT( element_header.type == nmd_type::NODE, "NODE expected!" ); 112 // m_node_names.push_back( element_header.name);113 load_ node( source, &m_node_array[i], element_header );109 m_node_array[i].data = data_channel_set_creator::create_set( element_header.children ); 110 load_channel_set( source, m_node_array[i].data, element_header ); 114 111 } 115 112 m_node_data = new mesh_nodes_data( e.name, e.children, m_node_array, animation_header.frame_rate, animation_header.duration, animation_header.flat ); 116 return true;117 }118 119 bool nv::nmd_loader::load_node( stream& source, mesh_node_data* data, const nmd_element_header& e )120 {121 data->data = data_channel_set_creator::create_set( e.children );122 if ( e.children > 0 )123 {124 load_channel_set( source, data->data, e );125 }126 data_channel_set_creator access( data->data );127 access.set_name( e.name );128 access.set_parent_id( e.parent_id );129 access.set_transform( e.transform );130 113 return true; 131 114 } … … 148 131 load_channel( source, channel_set ); 149 132 } 133 data_channel_set_creator access( channel_set ); 134 access.set_name( e.name ); 135 access.set_parent_id( e.parent_id ); 136 access.set_transform( e.transform ); 150 137 return true; 151 138 } … … 155 142 if ( m_node_data ) 156 143 { 157 // if ( m_strings )158 // {159 // for ( uint32 i = 0; i < m_node_data->get_count(); ++i )160 // {161 // m_node_array[i].name = m_strings->get( m_node_names[i] );162 // m_node_array[i].name_hash = hash_string< uint64 >( m_strings->get( m_node_names[i] ) );163 // }164 // }165 144 mesh_nodes_data* result = m_node_data; 166 145 m_node_data = nullptr; … … 203 182 nmd_element_header eheader; 204 183 eheader.type = nmd_type::NODE; 205 // eheader.name = strings->insert( node->name );206 184 eheader.children = static_cast<uint16>( chan_count ); 207 185 eheader.size = chan_size; -
trunk/src/formats/obj_loader.cc
r424 r425 291 291 }; 292 292 293 nv::obj_loader::obj_loader( bool normals /*= true*/, bool tangents /*= false */ )294 : m _normals( normals ), m_tangents( tangents )293 nv::obj_loader::obj_loader( string_table* strings, bool normals /*= true*/, bool tangents /*= false */ ) 294 : mesh_loader( strings ), m_normals( normals ), m_tangents( tangents ) 295 295 { 296 296 if ( normals ) … … 327 327 328 328 data_channel_set* result = data_channel_set_creator::create_set( 1 ); 329 data_channel_set_creator raccess( result );// ( reader->name ); 329 data_channel_set_creator raccess( result ); 330 raccess.set_name( make_name( reader->name ) ); 330 331 uint8* rdata = raccess.add_channel( m_descriptor, reader->size * 3 ).raw_data(); 331 332 -
trunk/src/io/string_table.cc
r422 r425 13 13 m_map.reserve( entry_count ); 14 14 indexer_type::value_type entry; 15 for ( uint32 i = 0; i < entry_count; )15 for ( uint32 i = 0; i < entry_count; i++ ) 16 16 { 17 17 in.read( &entry, sizeof( entry ), 1 );
Note: See TracChangeset
for help on using the changeset viewer.