Changeset 415
- Timestamp:
- 07/09/15 20:02:58 (10 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/formats/md5_loader.hh
r412 r415 84 84 void reset(); 85 85 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( m d5_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 ); 87 87 protected: 88 88 file_type m_type; -
trunk/nv/gfx/animation.hh
r414 r415 90 90 static uint32 get_raw( const raw_data_channel* channel, uint32 index, float* result ) 91 91 { 92 if ( channel-> element_count() == 0 ) return 0;92 if ( channel->size() == 0 ) return 0; 93 93 uint32 keyfsize = channel->element_size() / 4; 94 94 const float* fdata = reinterpret_cast<const float*>( channel->raw_data() ) + keyfsize * index; … … 102 102 static uint32 interpolate_raw( const raw_data_channel* channel, float time, float* result ) 103 103 { 104 if ( channel-> element_count() == 0 ) return 0;104 if ( channel->size() == 0 ) return 0; 105 105 uint32 keyfsize = channel->element_size() / 4; 106 106 uint32 keyfresult = keyfsize; … … 116 116 slot++; 117 117 keyfresult--; 118 if ( channel-> element_count() == 1 )118 if ( channel->size() == 1 ) 119 119 { 120 120 raw_copy_n( fdata + 1, keyfresult, result ); 121 121 return keyfresult; 122 122 } 123 for ( unsigned i = 1; i < channel-> element_count(); i++ )123 for ( unsigned i = 1; i < channel->size(); i++ ) 124 124 { 125 125 if ( time < fdata[i * keyfsize] ) … … 138 138 else 139 139 { 140 if ( channel-> element_count() == 1 )140 if ( channel->size() == 1 ) 141 141 { 142 142 raw_copy_n( fdata, keyfresult, result ); 143 143 return keyfresult; 144 144 } 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 ); 146 146 index1 = index0 + 1; 147 147 factor = glm::clamp<float>( time - index0, 0.0f, 1.0f ); 148 148 } 149 149 uint32 ret = 0; 150 for ( ; slot < channel->descriptor().s lot_count(); ++slot )150 for ( ; slot < channel->descriptor().size(); ++slot ) 151 151 { 152 152 ret += nv::interpolate_raw( … … 187 187 NV_ASSERT( m_data, "Data is null!" ); 188 188 const KEY* keys = m_data->data_cast<KEY>( ); 189 uint32 count = m_data-> element_count();189 uint32 count = m_data->size(); 190 190 if ( count == 0 ) return; 191 191 if ( count == 1 ) … … 221 221 NV_ASSERT( m_data, "Data is null!" ); 222 222 const KEY* keys = m_data->data_cast<KEY>( ); 223 uint32 count = m_data-> element_count();223 uint32 count = m_data->size(); 224 224 if ( count == 0 ) return; 225 225 if ( count == 1 ) … … 278 278 size_t size() const { return 0; } // TODO: remove? 279 279 bool empty() const { 280 return m_pchannel-> element_count() == 0281 && m_rchannel-> element_count() == 0282 && m_schannel-> element_count() == 0; }280 return m_pchannel->size() == 0 281 && m_rchannel->size() == 0 282 && m_schannel->size() == 0; } 283 283 virtual mat4 get_matrix( float time ) const 284 284 { … … 306 306 { 307 307 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 ); 311 311 } 312 312 ~key_vectors_prs() … … 342 342 delete m_channel; 343 343 } 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(); } 346 346 const transform& get( size_t index ) const { return m_channel->data_cast< key >()[ index ].tform; } 347 347 const transform* data() const { return &(m_channel->data_cast< key >()[0].tform); } … … 349 349 virtual uint32 raw_size() const 350 350 { 351 return sizeof( size_t ) + m_channel-> element_count() * sizeof( key );351 return sizeof( size_t ) + m_channel->size() * sizeof( key ); 352 352 } 353 353 -
trunk/nv/interface/context.hh
r412 r415 304 304 { 305 305 const raw_data_channel* channel = channels[ch]; 306 if ( channel-> element_count() > 0 )306 if ( channel->size() > 0 ) 307 307 { 308 308 const data_descriptor& desc = channel->descriptor(); -
trunk/nv/interface/data_descriptor.hh
r414 r415 222 222 bool operator==( const data_descriptor& rhs ) const 223 223 { 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 ) 227 227 { 228 228 if ( m_slots[i].etype != rhs.m_slots[i].etype ) return false; … … 236 236 void initialize() 237 237 { 238 m_ count= 0;238 m_size = 0; 239 239 initialize_slot< Struct, slot::POSITION >(); 240 240 initialize_slot< Struct, slot::TEXCOORD >(); … … 250 250 initialize_slot< Struct, slot::SCALE >(); 251 251 initialize_slot< Struct, slot::TFORM >(); 252 m_ size = sizeof( Struct );253 } 254 255 uint32 element_size() const { return m_ size; }256 uint32 s lot_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; } 257 257 258 258 bool has_slot( slot vslot ) const … … 264 264 265 265 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]; } 267 267 268 268 const data_descriptor_slot& operator []( uint32 i ) const 269 269 { 270 NV_ASSERT( i < m_ count, "data_descriptor indexing failure!" );270 NV_ASSERT( i < m_size, "data_descriptor indexing failure!" ); 271 271 return m_slots[i]; 272 272 } … … 274 274 void push_slot( datatype etype, slot vslot ) 275 275 { 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++; 281 281 } 282 282 … … 285 285 for ( const auto& dslot : desc ) 286 286 { 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++; 292 292 } 293 293 } … … 304 304 305 305 data_descriptor_slot m_slots[uint16( slot::MAX_STORE )]; 306 uint32 m_count = 0;307 306 uint32 m_size = 0; 307 uint32 m_element_size = 0; 308 308 309 309 template < typename Struct, slot Slot > … … 311 311 { 312 312 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 ) 315 315 { 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++; 319 319 } 320 320 } … … 323 323 struct raw_data_channel 324 324 { 325 raw_data_channel() : m_data( nullptr ), m_ count( 0 ) {}325 raw_data_channel() : m_data( nullptr ), m_size( 0 ) {} 326 326 ~raw_data_channel() 327 327 { … … 331 331 const data_descriptor& descriptor() const { return m_desc; } 332 332 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(); } 335 335 const uint8* raw_data() const { return m_data; } 336 336 … … 345 345 346 346 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 >365 347 friend class data_channel_creator; 366 348 friend class raw_data_channel_creator; … … 369 351 uint8* m_data; 370 352 data_descriptor m_desc; 371 uint32 m_ count;353 uint32 m_size; 372 354 373 355 }; … … 378 360 raw_data_channel_creator( const data_descriptor& desc, uint32 size ) 379 361 { 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 ); 381 366 m_owned = true; 382 367 } … … 388 373 389 374 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(); } 392 377 uint8* raw_data() { return m_channel->m_data; } 393 378 const uint8* raw_data() const { return m_channel->m_data; } … … 428 413 const Struct& operator []( uint32 i ) const 429 414 { 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!" ); 431 416 return reinterpret_cast< const Struct* >( m_channel->m_data )[i]; 432 417 } … … 434 419 Struct& operator []( uint32 i ) 435 420 { 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!" ); 437 422 return reinterpret_cast<Struct*>( m_channel->m_data )[i]; 438 423 } -
trunk/nv/interface/interpolation_raw.hh
r410 r415 59 59 inline mat4 extract_matrix_raw( const data_descriptor& desc, const float* data ) 60 60 { 61 if ( desc.s lot_count() == 1 )61 if ( desc.size() == 1 ) 62 62 { 63 63 switch ( desc[0].vslot ) … … 100 100 inline transform extract_transform_raw( const data_descriptor& desc, const float* data ) 101 101 { 102 if ( desc.s lot_count() == 1 )102 if ( desc.size() == 1 ) 103 103 { 104 104 switch ( desc[0].vslot ) -
trunk/nv/interface/mesh_data.hh
r413 r415 35 35 NV_ASSERT( channel, "nullptr passed to add_channel!" ); 36 36 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 ) 38 38 { 39 39 NV_ASSERT( !m_index_channel, "second index channel!" ); … … 68 68 69 69 70 // TODO: this should be "size" 70 71 size_t get_count() const 71 72 { 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(); 74 75 return 0; 75 76 } … … 77 78 size_t get_count( size_t channel ) const 78 79 { 79 if ( m_channels.size() > channel ) return m_channels[channel]-> element_count();80 if ( m_channels.size() > channel ) return m_channels[channel]->size(); 80 81 return 0; 81 82 } -
trunk/src/formats/assimp_loader.cc
r413 r415 117 117 118 118 bool skinned = mesh->mNumBones > 0; 119 raw_data_channel* channel = nullptr; 119 120 data_descriptor desc; 120 121 if ( skinned ) 121 channel = raw_data_channel::create< assimp_skinned_vtx >( mesh->mNumVertices);122 desc.initialize< assimp_skinned_vtx >(); 122 123 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 127 128 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 else143 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 } 145 146 146 147 if ( skinned ) … … 179 180 } 180 181 } 182 data->add_channel( channel.release() ); 181 183 data->add_channel( ichannel.release() ); 182 184 } -
trunk/src/formats/md5_loader.cc
r413 r415 137 137 assert( m_type == MESH ); 138 138 mesh_data* mesh = new mesh_data("md5_mesh"); 139 raw_data_channel* ch_pntiw = nullptr;140 139 141 140 uint32 num_verts = 0; … … 160 159 md5_vtx_t* tdata = nullptr; 161 160 { 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 ); 165 164 tdata = ch_t.data(); 166 165 mesh->add_channel( ch_pnt.release() ); … … 168 167 // TODO: hack to prevent rendering 169 168 //ch_pntiw->m_count = 0; 170 mesh->add_channel( ch_pntiw );169 mesh->add_channel( ch_pntiw.release() ); 171 170 } 172 171 weight_info.resize( num_verts ); … … 236 235 } 237 236 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() ); 239 238 240 239 m_meshes[ num_meshes ] = mesh; … … 258 257 nodes[i].target_id = -1; 259 258 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() ); 261 261 next_line( sstream ); 262 262 } … … 335 335 } 336 336 337 bool md5_loader::prepare_mesh( m d5_vtx_pntiw* vtx_data, mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info )337 bool md5_loader::prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info ) 338 338 { 339 339 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(); 342 344 343 345 for ( uint32 i = 0; i < vtx_count; ++i ) … … 488 490 const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->raw_data() ); 489 491 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 ]; 491 493 vec3 rot_pos = ptr.get_orientation() * pos; 492 494 -
trunk/src/formats/nmd_loader.cc
r413 r415 189 189 nmd_stream_header sheader; 190 190 sheader.format = chan->descriptor(); 191 sheader.count = chan-> element_count();191 sheader.count = chan->size(); 192 192 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() ); 194 194 } 195 195 } … … 257 257 nmd_stream_header cheader; 258 258 cheader.format = channel->descriptor(); 259 cheader.count = channel-> element_count();259 cheader.count = channel->size(); 260 260 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() ); 262 262 } 263 263 } -
trunk/src/gfx/keyframed_mesh.cc
r413 r415 23 23 , m_active( false ) 24 24 { 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(); 27 27 m_vchannel = m_mesh_data->get_channel<vertex_pnt>(); 28 28 m_vsize = sizeof( vertex_pnt ); … … 34 34 m_vsize = sizeof( vertex_pn ); 35 35 } 36 m_frame_count = m_vchannel-> element_count() / m_vertex_count;36 m_frame_count = m_vchannel->size() / m_vertex_count; 37 37 m_pbuffer = buffer(); 38 38 } -
trunk/src/gfx/mesh_creator.cc
r413 r415 19 19 key_data* keys = m_data->m_nodes[i].data; 20 20 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 ); 23 23 max_frames = nv::max<uint32>( count, max_frames ); 24 24 if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 ) … … 58 58 size_t chan_count = old_keys->get_channel_count(); 59 59 if ( chan_count == 1 60 && old_keys->get_channel(0)->descriptor().s lot_count() == 160 && old_keys->get_channel(0)->descriptor().size() == 1 61 61 && old_keys->get_channel(0)->descriptor()[0].etype == TRANSFORM ) continue; 62 62 … … 64 64 for ( size_t c = 0; c < chan_count; ++c ) 65 65 { 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() ); 67 67 } 68 68 … … 78 78 for ( uint16 c = 0; c < chan_count; ++c ) 79 79 { 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 ); 81 81 pkey += old_keys->get_raw( old_keys->get_channel(c), idx, pkey ); 82 82 } … … 242 242 if ( !p_channel || !n_channel || !t_channel ) return; 243 243 244 if ( p_channel-> element_count() != n_channel->element_count()245 || p_channel-> element_count() % t_channel->element_count() != 0244 if ( p_channel->size() != n_channel->size() 245 || p_channel->size() % t_channel->size() != 0 246 246 || ( i_type != UINT && i_type != USHORT && i_type != NONE ) ) 247 247 { … … 249 249 } 250 250 251 data_channel_creator< vertex_g > g_channel( p_channel-> element_count() );251 data_channel_creator< vertex_g > g_channel( p_channel->size() ); 252 252 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(); 257 257 258 258 for ( unsigned int i = 0; i < tri_count; ++i ) … … 292 292 for ( uint32 set = 0; set < sets; ++set ) 293 293 { 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; 297 297 const vec3& v1 = *reinterpret_cast<const vec3*>(p_channel->raw_data() + p_channel->element_size()*nti0 + p_offset ); 298 298 const vec3& v2 = *reinterpret_cast<const vec3*>(p_channel->raw_data() + p_channel->element_size()*nti1 + p_offset ); … … 337 337 nv::raw_data_channel* nv::mesh_data_creator::merge_channels( raw_data_channel* a, raw_data_channel* b ) 338 338 { 339 NV_ASSERT( a-> element_count() == b->element_count(), "merge_channel - bad channels!" );339 NV_ASSERT( a->size() == b->size(), "merge_channel - bad channels!" ); 340 340 data_descriptor desc = a->descriptor(); 341 341 desc.append( b->descriptor() ); 342 342 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 ) 345 345 { 346 346 raw_copy_n( a->raw_data() + i * a->element_size(), a->element_size(), result.raw_data() + i*desc.element_size() ); … … 354 354 { 355 355 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; 358 358 size_t vtx_size = a->element_size(); 359 359 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() ); 361 361 362 362 if ( frame_count == 1 ) 363 363 { 364 size_t a_size = vtx_size * a-> element_count();364 size_t a_size = vtx_size * a->size(); 365 365 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 ); 367 367 } 368 368 else 369 369 { 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; 372 372 size_t pos_a = 0; 373 373 size_t pos_b = 0; … … 406 406 int och_ti = other->get_channel_index( slot::TEXCOORD ); 407 407 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(); 412 412 if ( count % size != 0 || ocount % osize != 0 ) return; 413 413 if ( count / size != ocount / osize ) return; … … 416 416 { 417 417 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 ); 420 420 m_data->m_channels[c] = append_channels( old, other->m_channels[c], frame_count ); 421 421 NV_ASSERT( m_data->m_channels[c], "Merge problem!" ); … … 429 429 raw_data_channel_creator ic( m_data->m_channels[c] ); 430 430 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 ) 432 432 indexes[i] += uint16( size ); 433 433 … … 438 438 raw_data_channel_creator ic( m_data->m_channels[c] ); 439 439 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 ) 441 441 indexes[i] += size; 442 442 } -
trunk/src/gfx/skeletal_mesh.cc
r413 r415 17 17 const raw_data_channel* pntiw_chan = a_mesh_data->get_channel<md5_vtx_pntiw>(); 18 18 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() ); 20 20 m_bone_offset.resize( bones->get_count() ); 21 21 m_transform.resize( bones->get_count() ); … … 34 34 { 35 35 const raw_data_channel* channel = channels[ch]; 36 if ( channel-> element_count() > 0 && channel != pntiw_chan )36 if ( channel->size() > 0 && channel != pntiw_chan ) 37 37 { 38 38 const data_descriptor& desc = channel->descriptor();
Note: See TracChangeset
for help on using the changeset viewer.