From 5c8ee551d26f6d883d40b5c1a9f36b2b0eac2756 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 4 Dec 2022 19:22:32 +0000 Subject: We need to transform the model normals the same as we do the vertices --- gfx/models/obj.impl.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp index d73d82e..205abc8 100644 --- a/gfx/models/obj.impl.cpp +++ b/gfx/models/obj.impl.cpp @@ -19,15 +19,18 @@ ObjParser::ObjParser(std::unique_ptr in) : yyFlexLexer(in.get()) assert(in); ObjParser::yylex(); assert(in->good()); - std::for_each(vertices.begin(), vertices.end(), [](auto & v) { - constexpr const glm::mat4 obj2ilt { - -1, 0, 0, 0, // x - 0, 0, 1, 0, // y - 0, 1, 0, 0, // z - 0, 0, 0, 0, // w - }; + constexpr const glm::mat4 obj2ilt { + -1, 0, 0, 0, // x + 0, 0, 1, 0, // y + 0, 1, 0, 0, // z + 0, 0, 0, 0, // w + }; + std::for_each(vertices.begin(), vertices.end(), [&obj2ilt](auto & v) { v = v * obj2ilt; }); + std::for_each(normals.begin(), normals.end(), [&obj2ilt](auto & v) { + v = glm::vec4 {v, 0} * obj2ilt; + }); } ObjParser::NamedMeshes -- cgit v1.2.3