Changeset 406 for trunk/src/gfx/keyframed_mesh.cc
- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r395 r406 71 71 if ( m_active ) 72 72 { 73 float tick_time = ( (float)a_anim_time* 0.001f ) * anim->get_frame_rate();73 float tick_time = ( static_cast<float>( a_anim_time ) * 0.001f ) * anim->get_frame_rate(); 74 74 float duration = anim->is_looping() ? anim->get_duration() + 1.0f : anim->get_duration(); 75 75 if ( tick_time >= duration ) … … 82 82 { 83 83 m_active = false; 84 m_last_frame = (uint32)anim->get_end();84 m_last_frame = static_cast<uint32>( anim->get_end() ); 85 85 m_next_frame = m_last_frame; 86 86 m_interpolation = 0.0f; … … 88 88 } 89 89 } 90 m_last_frame = (uint32)( glm::floor( tick_time ) + anim->get_start() );90 m_last_frame = static_cast<uint32>( glm::floor( tick_time ) + anim->get_start() ); 91 91 m_next_frame = m_last_frame + 1; 92 if ( m_next_frame > (uint32)anim->get_end() ) m_next_frame = (uint32)anim->get_start();92 if ( m_next_frame > static_cast<uint32>( anim->get_end() ) ) m_next_frame = static_cast<uint32>( anim->get_start() ); 93 93 m_interpolation = tick_time - glm::floor( tick_time ); 94 94 } … … 152 152 { 153 153 uint32 base_offset = m_next_frame * m_vertex_count * m_vsize; 154 m_context->update_attribute_offset( m_va, (slot)m_loc_next_position, base_offset );155 m_context->update_attribute_offset( m_va, (slot)m_loc_next_normal, base_offset + sizeof( vec3 ) );154 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_position ), base_offset ); 155 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_normal ), base_offset + sizeof( vec3 ) ); 156 156 if ( m_has_tangent && m_loc_next_tangent != -1 ) 157 157 { 158 m_context->update_attribute_offset( m_va, (slot)m_loc_next_tangent, base_offset + 2*sizeof( vec3 ) );158 m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_tangent ), base_offset + 2*sizeof( vec3 ) ); 159 159 } 160 160 m_gpu_next_frame = m_next_frame; … … 172 172 m_loc_next_tangent = dev->get_attribute_location( a_program, "nv_next_tangent" ); 173 173 174 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_position, m_pbuffer, FLOAT, 3, 0, m_vsize, false );175 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_normal, m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );174 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_position ), m_pbuffer, FLOAT, 3, 0, m_vsize, false ); 175 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_normal ), m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false ); 176 176 if ( m_has_tangent ) 177 m_context->add_vertex_buffer( m_va, (slot)m_loc_next_tangent, m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );177 m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_tangent ), m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false ); 178 178 } 179 179 keyframed_mesh::update( a_program ); … … 184 184 { 185 185 m_va = m_context->create_vertex_array(); 186 m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );186 m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, m_vchannel->data ); 187 187 m_context->add_vertex_buffers( m_va, m_pbuffer, m_vchannel ); 188 188 189 buffer vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );189 buffer vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), m_mesh_data->get_channel<vertex_t>()->data ); 190 190 m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() ); 191 191 192 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );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 194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true ); … … 206 206 const vertex_pnt* prev = data + m_vertex_count * m_last_frame; 207 207 const vertex_pnt* next = data + m_vertex_count * m_next_frame; 208 vertex_pnt* vtx = (vertex_pnt*)m_data;208 vertex_pnt* vtx = reinterpret_cast<vertex_pnt*>( m_data ); 209 209 for ( size_t i = 0; i < m_vertex_count; ++i ) 210 210 { … … 219 219 const vertex_pn* prev = data + m_vertex_count * m_last_frame; 220 220 const vertex_pn* next = data + m_vertex_count * m_next_frame; 221 vertex_pn* vtx = (vertex_pn*)m_data;221 vertex_pn* vtx = reinterpret_cast<vertex_pn*>( m_data ); 222 222 223 223 for ( size_t i = 0; i < m_vertex_count; ++i )
Note: See TracChangeset
for help on using the changeset viewer.