From ff3e9263efa1cee146d262b80f686c8d64ffc628 Mon Sep 17 00:00:00 2001 From: trent Date: Thu, 20 Jul 2017 11:40:42 -0400 Subject: [PATCH] Stupid tabs. --- libraries/fbx/src/OBJReader.cpp | 86 ++++++++++++++++----------------- libraries/fbx/src/OBJReader.h | 8 +-- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp index 5beec4c1f4..d711ef87a3 100644 --- a/libraries/fbx/src/OBJReader.cpp +++ b/libraries/fbx/src/OBJReader.cpp @@ -124,31 +124,31 @@ glm::vec3 OBJTokenizer::getVec3() { return v; } bool OBJTokenizer::getVec3Vec3(glm::vec3& vertex, glm::vec3& vertexColor) { - // Used for vertices which may also have a vertex color (RGB [0,1]) to follow. - // NOTE: Returns true if there is a vertex color. - auto x = getFloat(); // N.B.: getFloat() has side-effect - auto y = getFloat(); // And order of arguments is different on Windows/Linux. - auto z = getFloat(); - vertex = glm::vec3(x, y, z); + // Used for vertices which may also have a vertex color (RGB [0,1]) to follow. + // NOTE: Returns true if there is a vertex color. + auto x = getFloat(); // N.B.: getFloat() has side-effect + auto y = getFloat(); // And order of arguments is different on Windows/Linux. + auto z = getFloat(); + vertex = glm::vec3(x, y, z); - auto r = 1.0f, g = 1.0f, b = 1.0f; - bool hasVertexColor = false; - if (isNextTokenFloat()) { - // If there's another float it's one of two things: a W component or an R component. The standard OBJ spec doesn't output a W component, - // so we're making the assumption that if a float follows (unless it's only a single value) that it's a vertex color. - r = getFloat(); - if(isNextTokenFloat()) { - // Safe to assume the following values are the green/blue components. - g = getFloat(); - b = getFloat(); + auto r = 1.0f, g = 1.0f, b = 1.0f; + bool hasVertexColor = false; + if (isNextTokenFloat()) { + // If there's another float it's one of two things: a W component or an R component. The standard OBJ spec doesn't output a W component, + // so we're making the assumption that if a float follows (unless it's only a single value) that it's a vertex color. + r = getFloat(); + if(isNextTokenFloat()) { + // Safe to assume the following values are the green/blue components. + g = getFloat(); + b = getFloat(); - hasVertexColor = true; - } + hasVertexColor = true; + } - vertexColor = glm::vec3(r, g, b); - } + vertexColor = glm::vec3(r, g, b); + } - return hasVertexColor; + return hasVertexColor; } glm::vec2 OBJTokenizer::getVec2() { float uCoord = getFloat(); @@ -410,14 +410,14 @@ bool OBJReader::parseOBJGroup(OBJTokenizer& tokenizer, const QVariantHash& mappi #endif } } else if (token == "v") { - glm::vec3 vertex, vertexColor; + glm::vec3 vertex, vertexColor; - bool hasVertexColor = tokenizer.getVec3Vec3(vertex, vertexColor); + bool hasVertexColor = tokenizer.getVec3Vec3(vertex, vertexColor); vertices.append(vertex); - - if(hasVertexColor) { - vertexColors.append(vertexColor); - } + + if(hasVertexColor) { + vertexColors.append(vertexColor); + } } else if (token == "vn") { normals.append(tokenizer.getVec3()); } else if (token == "vt") { @@ -575,14 +575,14 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping, glm::vec3 v1 = checked_at(vertices, face.vertexIndices[1]); glm::vec3 v2 = checked_at(vertices, face.vertexIndices[2]); - glm::vec3 vc0, vc1, vc2; - bool hasVertexColors = ( vertexColors.size( ) > 0 ); - if(hasVertexColors) { - // If there are any vertex colors, it's safe to assume all meshes had them exported. - vc0 = checked_at(vertexColors, face.vertexIndices[0]); - vc1 = checked_at(vertexColors, face.vertexIndices[1]); - vc2 = checked_at(vertexColors, face.vertexIndices[2]); - } + glm::vec3 vc0, vc1, vc2; + bool hasVertexColors = ( vertexColors.size( ) > 0 ); + if(hasVertexColors) { + // If there are any vertex colors, it's safe to assume all meshes had them exported. + vc0 = checked_at(vertexColors, face.vertexIndices[0]); + vc1 = checked_at(vertexColors, face.vertexIndices[1]); + vc2 = checked_at(vertexColors, face.vertexIndices[2]); + } // Scale the vertices if the OBJ file scale is specified as non-one. if (scaleGuess != 1.0f) { @@ -599,12 +599,12 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping, meshPart.triangleIndices.append(mesh.vertices.count()); mesh.vertices << v2; - if( hasVertexColors ) { - // Add vertex colors. - mesh.colors << vc0; - mesh.colors << vc1; - mesh.colors << vc2; - } + if( hasVertexColors ) { + // Add vertex colors. + mesh.colors << vc0; + mesh.colors << vc1; + mesh.colors << vc2; + } glm::vec3 n0, n1, n2; if (face.normalIndices.count()) { @@ -740,8 +740,8 @@ void fbxDebugDump(const FBXGeometry& fbxgeo) { qCDebug(modelformat) << " offset =" << fbxgeo.offset; qCDebug(modelformat) << " meshes.count() =" << fbxgeo.meshes.count(); foreach (FBXMesh mesh, fbxgeo.meshes) { - qCDebug(modelformat) << " vertices.count() =" << mesh.vertices.count(); - qCDebug(modelformat) << " colors.count() =" << mesh.colors.count(); + qCDebug(modelformat) << " vertices.count() =" << mesh.vertices.count(); + qCDebug(modelformat) << " colors.count() =" << mesh.colors.count(); qCDebug(modelformat) << " normals.count() =" << mesh.normals.count(); /*if (mesh.normals.count() == mesh.vertices.count()) { for (int i = 0; i < mesh.normals.count(); i++) { diff --git a/libraries/fbx/src/OBJReader.h b/libraries/fbx/src/OBJReader.h index 6765be9076..2b81986361 100644 --- a/libraries/fbx/src/OBJReader.h +++ b/libraries/fbx/src/OBJReader.h @@ -19,8 +19,8 @@ public: void pushBackToken(int token) { _pushedBackToken = token; } void ungetChar(char ch) { _device->ungetChar(ch); } const QString getComment() const { return _comment; } - glm::vec3 getVec3(); - bool getVec3Vec3(glm::vec3& vertex, glm::vec3& vertexColor); + glm::vec3 getVec3(); + bool getVec3Vec3(glm::vec3& vertex, glm::vec3& vertexColor); glm::vec2 getVec2(); float getFloat() { return std::stof((nextToken() != OBJTokenizer::DATUM_TOKEN) ? nullptr : getDatum().data()); } @@ -66,8 +66,8 @@ class OBJReader: public QObject { // QObject so we can make network requests. Q_OBJECT public: typedef QVector FaceGroup; - QVector vertices; - QVector vertexColors; + QVector vertices; + QVector vertexColors; QVector textureUVs; QVector normals; QVector faceGroups;