Changeset 1277


Ignore:
Timestamp:
Apr 23, 2012, 8:42:06 AM (11 years ago)
Author:
sam
Message:

orbital: fix normals in the case of non-uniform scaling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/mesh.h

    r1276 r1277  
    447447    void Scale(vec3 const &s)
    448448    {
    449         /* FIXME: this code breaks normals! */
     449        vec3 const invs = vec3(1) / s;
     450
    450451        for (int i = m_vert_cursor; i < m_vert.Count(); i++)
    451452        {
    452453            m_vert[i].m1 *= s;
    453             m_vert[i].m2 *= s;
    454         }
    455 
    456         // BH : TODO : not sure about this one
    457         // Sam: not too sure either!
     454            m_vert[i].m2 = normalize(m_vert[i].m2 * invs);
     455        }
     456
     457        /* Flip winding if the scaling involves mirroring */
    458458        if (s.x * s.y * s.z < 0)
    459459        {
Note: See TracChangeset for help on using the changeset viewer.