Changeset 454 for trunk/src/engine


Ignore:
Timestamp:
07/31/15 20:25:22 (10 years ago)
Author:
epyon
Message:
  • math library work
  • glm only referenced in math/common.hh
  • still a lot work to do, but its WURF
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine/particle_engine.cc

    r453 r454  
    231231        datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) );
    232232        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 ) );
    234234        return true;
    235235}
     
    242242                particle& pt = p[i];
    243243                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 )
    245245                {
    246                         float val = glm::dot( datap->plane_normal, pt.position ) + datap->distance;
     246                        float val = math::dot( datap->plane_normal, pt.position ) + datap->distance;
    247247                        if ( val > 0.0f )
    248248                        {
    249                                 vec3 part_dir = direction * ( -val / glm::dot( datap->plane_normal, direction ) );
     249                                vec3 part_dir = direction * ( -val / math::dot( datap->plane_normal, direction ) );
    250250                                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;
    252252                        }
    253253                }
     
    273273        for ( uint32 i = 0; i < count; ++i )
    274274        {
    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 );
    276276        }
    277277}
     
    296296        for ( uint32 i = 0; i < count; ++i )
    297297        {
    298                 p[i].size = glm::max( p[i].size + adjustment, vec2() );
     298                p[i].size = math::max( p[i].size + adjustment, vec2() );
    299299        }
    300300}
     
    347347        }
    348348
    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) ) );
    351351
    352352        vec2 def_size        = table.get<vec2>("size", vec2(0.1,0.1) );
     
    409409
    410410                                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) ) );
    412412                               
    413413                                edata.odir = vec3( 0, 0, 1 );
    414414                                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 );
    416417
    417418                                data.emmiter_count++;
     
    563564                m_model_matrix = s.get_model();
    564565                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());
    566567
    567568                update_emmiters( info, m_last_update );
     
    636637
    637638                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 );
    639640
    640641                switch ( orientation )
    641642                {
    642643                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 );
    645646                        break;
    646647                case particle_orientation::ORIENTED :
    647648                        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 ) );
    650651                        break;
    651652                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 ) );
    654655                        break;
    655656                case particle_orientation::PERPENDICULAR :
    656657                        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 ) );
    659660                        break;
    660661                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 ) );
    663664                        break;
    664665                }
Note: See TracChangeset for help on using the changeset viewer.