From c42753338924bb29c61081c9f269772f89bcd808 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Fri, 18 Aug 2017 18:18:25 +0200 Subject: Modernize various files (src/m*) (#6267) * Modernize various files (src/m*) * range-based for loops * code style * C++ headers instead of C headers * Default operators * empty function Thanks to clang-tidy --- src/mesh.cpp | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) (limited to 'src/mesh.cpp') diff --git a/src/mesh.cpp b/src/mesh.cpp index 3ab67510a..218e2d0b2 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -453,11 +453,7 @@ scene::IMesh* convertNodeboxesToMesh(const std::vector &boxes, video::SColor c(255,255,255,255); - for (std::vector::const_iterator - i = boxes.begin(); - i != boxes.end(); ++i) - { - aabb3f box = *i; + for (aabb3f box : boxes) { box.repair(); box.MinEdge.X -= expand; @@ -614,9 +610,8 @@ class f_lru public: f_lru(vcache *v, tcache *t): vc(v), tc(t) { - for (u16 i = 0; i < cachesize; i++) - { - cache[i] = -1; + for (int &i : cache) { + i = -1; } } @@ -671,15 +666,14 @@ public: } // Update triangle scores - for (u16 i = 0; i < cachesize; i++) - { - if (cache[i] == -1) + for (int i : cache) { + if (i == -1) break; - const u16 trisize = vc[cache[i]].tris.size(); + const u16 trisize = vc[i].tris.size(); for (u16 t = 0; t < trisize; t++) { - tcache *tri = &tc[vc[cache[i]].tris[t]]; + tcache *tri = &tc[vc[i].tris[t]]; tri->score = vc[tri->ind[0]].score + @@ -689,7 +683,7 @@ public: if (tri->score > hiscore) { hiscore = tri->score; - highest = vc[cache[i]].tris[t]; + highest = vc[i].tris[t]; } } } @@ -876,9 +870,8 @@ scene::IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh) tc[highest].drawn = true; - for (u16 j = 0; j < 3; j++) - { - vcache *vert = &vc[tc[highest].ind[j]]; + for (u16 j : tc[highest].ind) { + vcache *vert = &vc[j]; for (u16 t = 0; t < vert->tris.size(); t++) { if (highest == vert->tris[t]) @@ -988,9 +981,8 @@ scene::IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh) tc[highest].drawn = true; - for (u16 j = 0; j < 3; j++) - { - vcache *vert = &vc[tc[highest].ind[j]]; + for (u16 j : tc[highest].ind) { + vcache *vert = &vc[j]; for (u16 t = 0; t < vert->tris.size(); t++) { if (highest == vert->tris[t]) @@ -1101,9 +1093,8 @@ scene::IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh) tc[highest].drawn = true; - for (u16 j = 0; j < 3; j++) - { - vcache *vert = &vc[tc[highest].ind[j]]; + for (u16 j : tc[highest].ind) { + vcache *vert = &vc[j]; for (u16 t = 0; t < vert->tris.size(); t++) { if (highest == vert->tris[t]) -- cgit v1.2.3