aboutsummaryrefslogtreecommitdiff
path: root/src/sky.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-19 14:25:35 +0200
committerGitHub <noreply@github.com>2017-08-19 14:25:35 +0200
commit7528986e4449febead9b18b6118f0b096f7cf800 (patch)
tree8e526c1403ba8d0689ab40a24165fc19d8a07e27 /src/sky.cpp
parent1992db1395d9c068327a7c08bac7a24ef7112274 (diff)
downloadminetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.gz
minetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.bz2
minetest-7528986e4449febead9b18b6118f0b096f7cf800.zip
Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial) * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Spelling: vertice -> vertex
Diffstat (limited to 'src/sky.cpp')
-rw-r--r--src/sky.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/sky.cpp b/src/sky.cpp
index d92697f30..0bc344b3f 100644
--- a/src/sky.cpp
+++ b/src/sky.cpp
@@ -68,13 +68,13 @@ Sky::Sky(s32 id, ITextureSource *tsrc):
m_materials[4].Lighting = true;
}
- for (u32 i = 0; i < SKY_STAR_COUNT; i++) {
- m_stars[i] = v3f(
+ for (v3f &star : m_stars) {
+ star = v3f(
myrand_range(-10000, 10000),
myrand_range(-10000, 10000),
myrand_range(-10000, 10000)
);
- m_stars[i].normalize();
+ star.normalize();
}
m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
@@ -184,19 +184,19 @@ void Sky::render()
vertices[1] = video::S3DVertex( 1, 0.08, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( 1, 0.12, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-1, 0.12, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
if (j == 0)
// Don't switch
{}
else if (j == 1)
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
+ vertex.Pos.rotateXZBy(90);
else if (j == 2)
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXZBy(-90);
else
// Switch from -Z (south) to +Z (north)
- vertices[i].Pos.rotateXZBy(-180);
+ vertex.Pos.rotateXZBy(-180);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}
@@ -208,19 +208,19 @@ void Sky::render()
vertices[1] = video::S3DVertex( 1, -1.0, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( 1, 0.08, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-1, 0.08, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
if (j == 0)
// Don't switch
{}
else if (j == 1)
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
+ vertex.Pos.rotateXZBy(90);
else if (j == 2)
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXZBy(-90);
else
// Switch from -Z (south) to +Z (north)
- vertices[i].Pos.rotateXZBy(-180);
+ vertex.Pos.rotateXZBy(-180);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}
@@ -252,13 +252,13 @@ void Sky::render()
vertices[1] = video::S3DVertex( 1, -0.05 + y, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( 1, 0.2 + y, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-1, 0.2 + y, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
if (wicked_time_of_day < 0.5)
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
+ vertex.Pos.rotateXZBy(90);
else
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXZBy(-90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}
@@ -274,10 +274,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -288,10 +288,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -300,10 +300,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, suncolor, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, suncolor, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, suncolor, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -312,10 +312,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, suncolor2, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, suncolor2, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, suncolor2, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
} else {
@@ -330,10 +330,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for(u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}
@@ -350,10 +350,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -364,10 +364,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -376,10 +376,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, mooncolor, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, mooncolor, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, mooncolor, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
@@ -388,10 +388,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d2,-d, -1, 0, 0, 1, mooncolor2, o, t);
vertices[2] = video::S3DVertex( d2, d2, -1, 0, 0, 1, mooncolor2, o, o);
vertices[3] = video::S3DVertex(-d, d2, -1, 0, 0, 1, mooncolor2, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
} else {
@@ -406,10 +406,10 @@ void Sky::render()
vertices[1] = video::S3DVertex( d, -d, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( d, d, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-d, d, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
- vertices[i].Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
+ vertex.Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXYBy(wicked_time_of_day * 360 - 90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}
@@ -469,14 +469,14 @@ void Sky::render()
vertices[1] = video::S3DVertex( 1, -1.0, -1, 0, 0, 1, c, o, t);
vertices[2] = video::S3DVertex( 1, -0.02, -1, 0, 0, 1, c, o, o);
vertices[3] = video::S3DVertex(-1, -0.02, -1, 0, 0, 1, c, t, o);
- for (u32 i = 0; i < 4; i++) {
+ for (video::S3DVertex &vertex : vertices) {
//if (wicked_time_of_day < 0.5)
if (j == 0)
// Switch from -Z (south) to +X (east)
- vertices[i].Pos.rotateXZBy(90);
+ vertex.Pos.rotateXZBy(90);
else
// Switch from -Z (south) to -X (west)
- vertices[i].Pos.rotateXZBy(-90);
+ vertex.Pos.rotateXZBy(-90);
}
driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2);
}