Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/libraries/tools/IcoSphere.cc

    r10262 r11054  
    116116            std::list<TriangleIndices> faces2;
    117117
    118             for (std::list<TriangleIndices>::iterator j = faces.begin(); j != faces.end(); j++)
     118            for (const TriangleIndices& f : faces)
    119119            {
    120                 TriangleIndices f = *j;
    121120                int a = getMiddlePoint(f.v1, f.v2);
    122121                int b = getMiddlePoint(f.v2, f.v3);
     
    127126                removeLineIndices(f.v3, f.v1);
    128127
    129                 faces2.push_back(TriangleIndices(f.v1, a, c));
    130                 faces2.push_back(TriangleIndices(f.v2, b, a));
    131                 faces2.push_back(TriangleIndices(f.v3, c, b));
    132                 faces2.push_back(TriangleIndices(a, b, c));
     128                faces2.emplace_back(f.v1, a, c);
     129                faces2.emplace_back(f.v2, b, a);
     130                faces2.emplace_back(f.v3, c, b);
     131                faces2.emplace_back(a, b, c);
    133132
    134133                addTriangleLines(f.v1, a, c);
     
    143142    void IcoSphere::addLineIndices(int index0, int index1)
    144143    {
    145         lineIndices.push_back(LineIndices(index0, index1));
     144        lineIndices.emplace_back(index0, index1);
    146145    }
    147146
     
    164163    {
    165164        Ogre::Real length = vertex.length();
    166         vertices.push_back(Ogre::Vector3(vertex.x / length, vertex.y / length, vertex.z / length));
     165        vertices.emplace_back(vertex.x / length, vertex.y / length, vertex.z / length);
    167166        return index++;
    168167    }
     
    189188    void IcoSphere::addFace(int index0, int index1, int index2)
    190189    {
    191         faces.push_back(TriangleIndices(index0, index1, index2));
     190        faces.emplace_back(index0, index1, index2);
    192191    }
    193192
    194193    void IcoSphere::addToLineIndices(int baseIndex, std::list<int>* target) const
    195194    {
    196         for (std::list<LineIndices>::const_iterator i = lineIndices.begin(); i != lineIndices.end(); i++)
     195        for (const LineIndices& line : lineIndices)
    197196        {
    198             target->push_back(baseIndex + (*i).v1);
    199             target->push_back(baseIndex + (*i).v2);
     197            target->push_back(baseIndex + line.v1);
     198            target->push_back(baseIndex + line.v2);
    200199        }
    201200    }
     
    203202    void IcoSphere::addToTriangleIndices(int baseIndex, std::list<int>* target) const
    204203    {
    205         for (std::list<TriangleIndices>::const_iterator i = faces.begin(); i != faces.end(); i++)
     204        for (const TriangleIndices& triangle : faces)
    206205        {
    207             target->push_back(baseIndex + (*i).v1);
    208             target->push_back(baseIndex + (*i).v2);
    209             target->push_back(baseIndex + (*i).v3);
     206            target->push_back(baseIndex + triangle.v1);
     207            target->push_back(baseIndex + triangle.v2);
     208            target->push_back(baseIndex + triangle.v3);
    210209        }
    211210    }
     
    217216        transform.setScale(Ogre::Vector3(scale, scale, scale));
    218217
    219         for (int i = 0; i < (int) vertices.size(); i++)
    220             target->push_back(VertexPair(transform * vertices[i], colour));
     218        for (const Ogre::Vector3& vertex : vertices)
     219            target->emplace_back(transform * vertex, colour);
    221220
    222221        return vertices.size();
Note: See TracChangeset for help on using the changeset viewer.