Changeset 11054 for code/branches/cpp11_v3/src/libraries/tools/IcoSphere.cc
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/libraries/tools/IcoSphere.cc
r10262 r11054 116 116 std::list<TriangleIndices> faces2; 117 117 118 for ( std::list<TriangleIndices>::iterator j = faces.begin(); j != faces.end(); j++)118 for (const TriangleIndices& f : faces) 119 119 { 120 TriangleIndices f = *j;121 120 int a = getMiddlePoint(f.v1, f.v2); 122 121 int b = getMiddlePoint(f.v2, f.v3); … … 127 126 removeLineIndices(f.v3, f.v1); 128 127 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); 133 132 134 133 addTriangleLines(f.v1, a, c); … … 143 142 void IcoSphere::addLineIndices(int index0, int index1) 144 143 { 145 lineIndices. push_back(LineIndices(index0, index1));144 lineIndices.emplace_back(index0, index1); 146 145 } 147 146 … … 164 163 { 165 164 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); 167 166 return index++; 168 167 } … … 189 188 void IcoSphere::addFace(int index0, int index1, int index2) 190 189 { 191 faces. push_back(TriangleIndices(index0, index1, index2));190 faces.emplace_back(index0, index1, index2); 192 191 } 193 192 194 193 void IcoSphere::addToLineIndices(int baseIndex, std::list<int>* target) const 195 194 { 196 for ( std::list<LineIndices>::const_iterator i = lineIndices.begin(); i != lineIndices.end(); i++)195 for (const LineIndices& line : lineIndices) 197 196 { 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); 200 199 } 201 200 } … … 203 202 void IcoSphere::addToTriangleIndices(int baseIndex, std::list<int>* target) const 204 203 { 205 for ( std::list<TriangleIndices>::const_iterator i = faces.begin(); i != faces.end(); i++)204 for (const TriangleIndices& triangle : faces) 206 205 { 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); 210 209 } 211 210 } … … 217 216 transform.setScale(Ogre::Vector3(scale, scale, scale)); 218 217 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); 221 220 222 221 return vertices.size();
Note: See TracChangeset
for help on using the changeset viewer.