Skip to content

Commit

Permalink
Fix surface mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 27, 2017
1 parent fa0ec31 commit 7749e1b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/model/Lwo2Exporter.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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<uint16_t>(pols->stream, numVerts); // [U2]

// The three vertices defining this polygon (reverse indices to produce LWO2 windings)
Expand All @@ -352,6 +351,8 @@ void Lwo2Exporter::exportToStream(std::ostream& stream)
// The surface mapping in the PTAG
writeVariableIndex(ptag->stream, polyNum); // [VX]
stream::writeBigEndian<uint16_t>(ptag->stream, static_cast<uint16_t>(surfNum)); // [U2]

++polyNum;
}

// Write the SURF chunk for the surface
Expand Down

0 comments on commit 7749e1b

Please sign in to comment.