Changeset 454 for trunk/src/engine
- Timestamp:
- 07/31/15 20:25:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/engine/particle_engine.cc
r453 r454 231 231 datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) ); 232 232 datap->bounce = table->get<float>("bounce", 0.0f ); 233 datap->distance = - glm::dot( datap->plane_normal, datap->plane_point ) / math::sqrt(glm::dot( datap->plane_normal, datap->plane_normal ) );233 datap->distance = -math::dot( datap->plane_normal, datap->plane_point ) / math::sqrt( math::dot( datap->plane_normal, datap->plane_normal ) ); 234 234 return true; 235 235 } … … 242 242 particle& pt = p[i]; 243 243 vec3 direction = pt.velocity * factor; 244 if ( glm::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f )244 if ( math::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f ) 245 245 { 246 float val = glm::dot( datap->plane_normal, pt.position ) + datap->distance;246 float val = math::dot( datap->plane_normal, pt.position ) + datap->distance; 247 247 if ( val > 0.0f ) 248 248 { 249 vec3 part_dir = direction * ( -val / glm::dot( datap->plane_normal, direction ) );249 vec3 part_dir = direction * ( -val / math::dot( datap->plane_normal, direction ) ); 250 250 pt.position = pt.position + part_dir + ( part_dir - direction ) * datap->bounce; 251 pt.velocity = glm::reflect( pt.velocity, datap->plane_normal ) * datap->bounce;251 pt.velocity = math::reflect( pt.velocity, datap->plane_normal ) * datap->bounce; 252 252 } 253 253 } … … 273 273 for ( uint32 i = 0; i < count; ++i ) 274 274 { 275 p[i].color = glm::clamp( p[i].color + adjustment, 0.0f, 1.0f );275 p[i].color = math::clamp( p[i].color + adjustment, 0.0f, 1.0f ); 276 276 } 277 277 } … … 296 296 for ( uint32 i = 0; i < count; ++i ) 297 297 { 298 p[i].size = glm::max( p[i].size + adjustment, vec2() );298 p[i].size = math::max( p[i].size + adjustment, vec2() ); 299 299 } 300 300 } … … 347 347 } 348 348 349 data.common_up = glm::normalize( table.get<vec3>("common_up", vec3(1,0,0) ) );350 data.common_dir = glm::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) );349 data.common_up = math::normalize( table.get<vec3>("common_up", vec3(1,0,0) ) ); 350 data.common_dir = math::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) ); 351 351 352 352 vec2 def_size = table.get<vec2>("size", vec2(0.1,0.1) ); … … 409 409 410 410 edata.rate = element.get<float>("rate", 1.0f ); 411 edata.dir = glm::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );411 edata.dir = math::normalize( element.get<vec3>("direction", vec3(0,1,0) ) ); 412 412 413 413 edata.odir = vec3( 0, 0, 1 ); 414 414 if ( edata.dir != vec3( 0, 1, 0 ) && edata.dir != vec3( 0, -1, 0 ) ) 415 edata.odir = glm::normalize( glm::cross( edata.dir, vec3( 0, 1, 0 ) ) ); edata.cdir = glm::cross( edata.dir, edata.odir ); 415 edata.odir = math::normalize( math::cross( edata.dir, vec3( 0, 1, 0 ) ) ); 416 edata.cdir = math::cross( edata.dir, edata.odir ); 416 417 417 418 data.emmiter_count++; … … 563 564 m_model_matrix = s.get_model(); 564 565 m_camera_pos = s.get_camera().get_position(); 565 m_inv_view_dir = glm::normalize(-s.get_camera().get_direction());566 m_inv_view_dir = math::normalize(-s.get_camera().get_direction()); 566 567 567 568 update_emmiters( info, m_last_update ); … … 636 637 637 638 vec3 view_dir( m_inv_view_dir ); 638 if ( accurate_facing ) view_dir = glm::normalize( m_camera_pos - pdata.position );639 if ( accurate_facing ) view_dir = math::normalize( m_camera_pos - pdata.position ); 639 640 640 641 switch ( orientation ) 641 642 { 642 643 case particle_orientation::POINT : 643 right = glm::normalize( glm::cross( view_dir, vec3( 0, 1, 0 ) ) );644 rot_mat = mat3( right, glm::cross( right, -view_dir ), -view_dir );644 right = math::normalize( math::cross( view_dir, vec3( 0, 1, 0 ) ) ); 645 rot_mat = mat3( right, math::cross( right, -view_dir ), -view_dir ); 645 646 break; 646 647 case particle_orientation::ORIENTED : 647 648 pdir = normalize_safe( pdata.velocity, pdir ); 648 right = glm::normalize( glm::cross( pdir, view_dir ) );649 rot_mat = mat3( right, pdir, glm::cross( pdir, right ) );649 right = math::normalize( math::cross( pdir, view_dir ) ); 650 rot_mat = mat3( right, pdir, math::cross( pdir, right ) ); 650 651 break; 651 652 case particle_orientation::ORIENTED_COMMON : 652 right = glm::normalize( glm::cross( common_dir, view_dir ) );653 rot_mat = mat3( right, common_dir, glm::cross( common_dir, right ) );653 right = math::normalize( math::cross( common_dir, view_dir ) ); 654 rot_mat = mat3( right, common_dir, math::cross( common_dir, right ) ); 654 655 break; 655 656 case particle_orientation::PERPENDICULAR : 656 657 pdir = normalize_safe( pdata.velocity, pdir ); 657 right = glm::normalize( glm::cross( common_up, pdir ) );658 rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );658 right = math::normalize( math::cross( common_up, pdir ) ); 659 rot_mat = mat3( right, common_up, math::cross( common_up, right ) ); 659 660 break; 660 661 case particle_orientation::PERPENDICULAR_COMMON : 661 right = glm::normalize( glm::cross( common_up, common_dir ) );662 rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );662 right = math::normalize( math::cross( common_up, common_dir ) ); 663 rot_mat = mat3( right, common_up, math::cross( common_up, right ) ); 663 664 break; 664 665 }
Note: See TracChangeset
for help on using the changeset viewer.