From 01bf751598bdd3c04e31c7834ad3e339dd5708cc Mon Sep 17 00:00:00 2001 From: Sting <lallegre26@gmail.com> Date: Thu, 19 May 2022 03:10:02 +0200 Subject: [PATCH] Bug fixed : loaded shaped is properly drawn --- shape.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shape.lua b/shape.lua index 37b6d37..64ef73c 100644 --- a/shape.lua +++ b/shape.lua @@ -127,7 +127,7 @@ function shape.load(t, file) faceNumber = tonumber(matches[2]) else if vertexRead < vertexNumber then - vertices[#vertices+1] = {tonumber(matches[1]), tonumber(matches[2]), tonumber(matches[3])} + vertices[#vertices+1] = vector.new(3, {tonumber(matches[1]), tonumber(matches[2]), tonumber(matches[3])}) vertexRead = vertexRead + 1 else local faceSize = tonumber(matches[1]) @@ -135,8 +135,9 @@ function shape.load(t, file) for i = 1, faceSize do faceVertices[i] = vertices[tonumber(matches[i+1]) + 1] end - local normal = vector.cross(vector.new(3, faceVertices[2]) - vector.new(3, faceVertices[1]), - vector.new(3, faceVertices[3]) - vector.new(3, faceVertices[1])) + local normal = vector.cross(faceVertices[2] - faceVertices[1], + faceVertices[3] - faceVertices[1]) + :normalized() faces[#faces+1] = face.new(faceVertices, normal) facesRead = facesRead + 1 end -- GitLab