diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-09-07 15:29:01 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-09-08 13:41:34 +0000 |
commit | 377cab78bbbbbf37a3ed87e9eec7602c6cb6837e (patch) | |
tree | 90b8827c3c5588fd415ea845beb286f7d52d7502 /src/extras/geometries/qcuboidgeometry.cpp | |
parent | 73a386d4f62dcf83576d8f3e8b7ee7bb688b661d (diff) |
Fix non-symmetric extents and resolutions for QCuboidMesh
Task-number: QTBUG-55836
Change-Id: Ic5ee72f5ffb236fe15e46fa667159a139ad05b03
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/geometries/qcuboidgeometry.cpp')
-rw-r--r-- | src/extras/geometries/qcuboidgeometry.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/extras/geometries/qcuboidgeometry.cpp b/src/extras/geometries/qcuboidgeometry.cpp index f720f1367..4e644b24a 100644 --- a/src/extras/geometries/qcuboidgeometry.cpp +++ b/src/extras/geometries/qcuboidgeometry.cpp @@ -76,23 +76,23 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, switch (normal) { case NegativeX: // Iterate over z - for (int j = resolution.width() - 1; j >= 0; --j) { - const float a = a0 + static_cast<float>(j) * da; - const float u = static_cast<float>(j) * du; + for (int j = resolution.height() - 1; j >= 0; --j) { + const float b = b0 + static_cast<float>(j) * db; + const float v = static_cast<float>(j) * dv; // Iterate over y - for (int i = 0; i < resolution.height(); ++i) { - const float b = b0 + static_cast<float>(i) * db; - const float v = static_cast<float>(i) * dv; + for (int i = 0; i < resolution.width(); ++i) { + const float a = a0 + static_cast<float>(i) * da; + const float u = static_cast<float>(i) * du; // position *vertices++ = planeDistance; - *vertices++ = b; *vertices++ = a; + *vertices++ = b; // texture coordinates - *vertices++ = 1.0f - u; *vertices++ = v; + *vertices++ = u; // normal *vertices++ = -1.0f; @@ -102,8 +102,8 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, // tangent *vertices++ = 0.0f; *vertices++ = 0.0f; - *vertices++ = -1.0f; - *vertices++ = -1.0f; + *vertices++ = 1.0f; + *vertices++ = 1.0f; } } break; @@ -111,22 +111,22 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, case PositiveX: { // Iterate over z for (int j = 0; j < resolution.height(); ++j) { - const float a = a0 + static_cast<float>(j) * da; - const float u = static_cast<float>(j) * du; + const float b = b0 + static_cast<float>(j) * db; + const float v = static_cast<float>(j) * dv; // Iterate over y for (int i = 0; i < resolution.width(); ++i) { - const float b = b0 + static_cast<float>(i) * db; - const float v = static_cast<float>(i) * dv; + const float a = a0 + static_cast<float>(i) * da; + const float u = static_cast<float>(i) * du; // position *vertices++ = planeDistance; - *vertices++ = b; *vertices++ = a; + *vertices++ = b; // texture coordinates + *vertices++ = 1.0f - v; *vertices++ = u; - *vertices++ = v; // normal *vertices++ = 1.0f; @@ -136,8 +136,8 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, // tangent *vertices++ = 0.0f; *vertices++ = 0.0f; - *vertices++ = 1.0f; *vertices++ = -1.0f; + *vertices++ = 1.0f; } } break; |