Changeset 410 for trunk/src/gfx
- Timestamp:
- 07/08/15 17:33:38 (10 years ago)
- Location:
- trunk/src/gfx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r406 r410 192 192 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), m_mesh_data->get_index_channel()->data ); 193 193 194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc .slots[0].etype, true );194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc[0].etype, true ); 195 195 196 196 m_data = new uint8[ m_vertex_count * m_vsize ]; -
trunk/src/gfx/mesh_creator.cc
r406 r410 57 57 size_t chan_count = old_keys->get_channel_count(); 58 58 if ( chan_count == 1 59 && old_keys->get_channel(0)->desc. count== 160 && old_keys->get_channel(0)->desc .slots[0].etype == TRANSFORM ) continue;59 && old_keys->get_channel(0)->desc.slot_count() == 1 60 && old_keys->get_channel(0)->desc[0].etype == TRANSFORM ) continue; 61 61 62 62 size_t max_keys = 0; … … 70 70 new_keys->add_channel( raw_channel ); 71 71 nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(raw_channel->data); 72 key_descriptor final_key = old_keys->get_final_key();72 data_descriptor final_key = old_keys->get_final_key(); 73 73 74 74 for ( unsigned n = 0; n < max_keys; ++n ) … … 107 107 { 108 108 const key_raw_channel* channel = kdata->get_channel(c); 109 size_t key_size = channel->desc. size;109 size_t key_size = channel->desc.element_size(); 110 110 for ( size_t n = 0; n < channel->count; ++n ) 111 111 { … … 126 126 { 127 127 const mesh_raw_channel* channel = m_data->get_channel(c); 128 const vertex_descriptor& desc= channel->desc;128 const data_descriptor& desc = channel->desc; 129 129 uint8* raw_data = channel->data; 130 uint32 vtx_size = desc. size;130 uint32 vtx_size = desc.element_size(); 131 131 int p_offset = -1; 132 132 int n_offset = -1; 133 133 int t_offset = -1; 134 for ( uint32 i = 0; i < desc.count; ++i)135 switch ( desc.slots[i].vslot )136 { 137 case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = int(desc.slots[i].offset); break;138 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = int(desc.slots[i].offset); break;139 case slot::TANGENT : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = int(desc.slots[i].offset); break;134 for ( const auto& cslot : desc ) 135 switch ( cslot.vslot ) 136 { 137 case slot::POSITION : if ( cslot.etype == FLOAT_VECTOR_3 ) p_offset = int( cslot.offset ); break; 138 case slot::NORMAL : if ( cslot.etype == FLOAT_VECTOR_3 ) n_offset = int( cslot.offset ); break; 139 case slot::TANGENT : if ( cslot.etype == FLOAT_VECTOR_4 ) t_offset = int( cslot.offset ); break; 140 140 default : break; 141 141 } … … 174 174 if ( ch_n == -1 ) return; 175 175 mesh_raw_channel* channel = m_data->m_channels[ unsigned( ch_n ) ]; 176 for ( uint32 i = 0; i < channel->desc.count; ++i)177 if ( c hannel->desc.slots[i].vslot == slot::NORMAL )178 { 179 n_offset = c hannel->desc.slots[i].offset;176 for ( const auto& cslot : channel->desc ) 177 if ( cslot.vslot == slot::NORMAL ) 178 { 179 n_offset = cslot.offset; 180 180 } 181 181 182 182 for ( uint32 i = 0; i < channel->count; ++i ) 183 183 { 184 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc. size* i + n_offset );184 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.element_size() * i + n_offset ); 185 185 normal = -normal; 186 186 } … … 204 204 { 205 205 const mesh_raw_channel* channel = m_data->get_channel(c); 206 const vertex_descriptor& desc = channel->desc; 207 for ( uint32 i = 0; i < desc.count; ++i)208 switch ( desc.slots[i].vslot )206 207 for ( const auto& cslot : channel->desc ) 208 switch ( cslot.vslot ) 209 209 { 210 210 case slot::POSITION : 211 if ( desc.slots[i].etype == FLOAT_VECTOR_3 )212 { 213 p_offset = int( desc.slots[i].offset );211 if ( cslot.etype == FLOAT_VECTOR_3 ) 212 { 213 p_offset = int( cslot.offset ); 214 214 p_channel = channel; 215 215 } 216 216 break; 217 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 218 { 219 n_offset = int( desc.slots[i].offset ); 217 case slot::NORMAL : 218 if ( cslot.etype == FLOAT_VECTOR_3 ) 219 { 220 n_offset = int( cslot.offset ); 220 221 n_channel = m_data->m_channels[ c ]; 221 222 n_channel_index = c; 222 223 } 223 224 break; 224 case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 ) 225 { 226 t_offset = int( desc.slots[i].offset ); 225 case slot::TEXCOORD : 226 if ( cslot.etype == FLOAT_VECTOR_2 ) 227 { 228 t_offset = int( cslot.offset ); 227 229 t_channel = channel; 228 230 } … … 230 232 case slot::INDEX : 231 233 { 232 i_type = desc.slots[i].etype;234 i_type = cslot.etype; 233 235 i_channel = channel; 234 236 } … … 278 280 } 279 281 280 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti0 + t_offset );281 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti1 + t_offset );282 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti2 + t_offset );282 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti0 + t_offset ); 283 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti1 + t_offset ); 284 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti2 + t_offset ); 283 285 vec2 st1 = w3 - w1; 284 286 vec2 st2 = w2 - w1; … … 291 293 uint32 nti1 = t_channel->count * set + ti1; 292 294 uint32 nti2 = t_channel->count * set + ti2; 293 vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti0 + p_offset );294 vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti1 + p_offset );295 vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti2 + p_offset );295 vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti0 + p_offset ); 296 vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti1 + p_offset ); 297 vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti2 + p_offset ); 296 298 vec3 xyz1 = v3 - v1; 297 299 vec3 xyz2 = v2 - v1; … … 317 319 for ( unsigned int i = 0; i < vtx_count; ++i ) 318 320 { 319 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc. size*i + n_offset );321 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.element_size()*i + n_offset ); 320 322 const vec3 t = vec3(tangents[i]); 321 323 if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) ) … … 335 337 { 336 338 NV_ASSERT( a->count == b->count, "merge_channel - bad channels!" ); 337 vertex_descriptor adesc = a->desc; 338 vertex_descriptor bdesc = b->desc; 339 uint32 count = a->count; 340 341 vertex_descriptor desc = a->desc; 342 for ( uint32 i = 0; i < bdesc.count; i++ ) 343 { 344 desc.slots[desc.count+i] = bdesc.slots[i]; 345 desc.slots[desc.count+i].offset += desc.size; 346 } 347 desc.size += bdesc.size; 348 desc.count += bdesc.count; 349 uint8* data = new uint8[ count * desc.size ]; 339 data_descriptor adesc = a->desc; 340 data_descriptor bdesc = b->desc; 341 uint32 count = a->count; 342 343 data_descriptor desc = a->desc; 344 for ( auto bslot : bdesc ) 345 { 346 desc.push_slot( bslot.etype, bslot.vslot ); 347 } 348 uint8* data = new uint8[ count * desc.element_size() ]; 350 349 for ( uint32 i = 0; i < count; ++i ) 351 350 { 352 raw_copy_n( a->data + i * adesc. size, adesc.size, data + i*desc.size);353 raw_copy_n( b->data + i * bdesc. size, bdesc.size, data + i*desc.size + adesc.size);351 raw_copy_n( a->data + i * adesc.element_size(), adesc.element_size(), data + i*desc.element_size() ); 352 raw_copy_n( b->data + i * bdesc.element_size(), bdesc.element_size(), data + i*desc.element_size() + adesc.element_size() ); 354 353 } 355 354 mesh_raw_channel* result = new mesh_raw_channel; … … 365 364 if ( a->count % frame_count != 0 ) return nullptr; 366 365 if ( b->count % frame_count != 0 ) return nullptr; 367 size_t vtx_size = a->desc. size;366 size_t vtx_size = a->desc.element_size(); 368 367 369 368 uint8* data = new uint8[ ( a->count + b->count ) * vtx_size ]; … … 435 434 if ( old->get_buffer_type() == INDEX_BUFFER ) 436 435 { 437 switch ( old->desc .slots[0].etype )436 switch ( old->desc[0].etype ) 438 437 { 439 438 case USHORT :
Note: See TracChangeset
for help on using the changeset viewer.