From 7749e1bc032381f01088dc45f405a47572964c69 Mon Sep 17 00:00:00 2001 From: codereader Date: Thu, 27 Jul 2017 09:04:58 +0200 Subject: [PATCH] Fix surface mapping. --- plugins/model/Lwo2Exporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/model/Lwo2Exporter.cpp b/plugins/model/Lwo2Exporter.cpp index 7d64b1cf7b..eef0458025 100644 --- a/plugins/model/Lwo2Exporter.cpp +++ b/plugins/model/Lwo2Exporter.cpp @@ -310,6 +310,7 @@ void Lwo2Exporter::exportToStream(std::ostream& stream) writeString(vmap->stream, uvmapName); std::size_t vertexIdxStart = 0; + std::size_t polyNum = 0; // poly index is used across all surfaces // Load all vertex coordinates into this chunk for (std::size_t surfNum = 0; surfNum < _surfaces.size(); ++surfNum) @@ -340,8 +341,6 @@ void Lwo2Exporter::exportToStream(std::ostream& stream) for (std::size_t i = 0; i + 2 < surface.indices.size(); i += 3) { - std::size_t polyNum = i / 3; - stream::writeBigEndian(pols->stream, numVerts); // [U2] // The three vertices defining this polygon (reverse indices to produce LWO2 windings) @@ -352,6 +351,8 @@ void Lwo2Exporter::exportToStream(std::ostream& stream) // The surface mapping in the PTAG writeVariableIndex(ptag->stream, polyNum); // [VX] stream::writeBigEndian(ptag->stream, static_cast(surfNum)); // [U2] + + ++polyNum; } // Write the SURF chunk for the surface