aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-07-03 20:42:43 +0200
committerjackpoz <giacomopoz@gmail.com>2014-07-03 22:52:36 +0200
commit519d76c194b418d7440bc3c517aaa2d2a454024e (patch)
treeaad4707b993998db2b4339d9c0c6b4518e585cdc
parent7b74a725c89cca383acab8a002c162fc7ff1e0ac (diff)
Core/VMAPs: Fix object orientation
Merge https://github.com/249CAAFE40/mangos-wotlk/commit/2f8b8e55d99122d34be2a08cbdbd2d2b1ae172d1 Quoting original commit log: This patch fixes 2 issues with the vmap extractor. 1) Incorrectly converts vertex coordinates. 2) Forgets to convert coordinates on triangle indices. The effects of [1] causes models to be flipped. This isn't very noticeable on most trees as flipping a cylinder results in the same cylinder, but it's very noticeable on any non-symmetrical geometry (which, even includes trees, it's just harder to notice). [2] Didn't seem to be a problem when the coordinates were incorrectly converted, but when applying the correct conversion caused some triangles to be flipped (i.e. facing inwards). You will need to re-extract vmaps and re-generate mmaps for these changes to take effect. Fixes #417
-rw-r--r--src/tools/vmap4_extractor/model.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp
index 825a2697c16..c527ec32ddb 100644
--- a/src/tools/vmap4_extractor/model.cpp
+++ b/src/tools/vmap4_extractor/model.cpp
@@ -96,8 +96,19 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&nIndexes, sizeof(uint32), 1, output);
- if (nIndexes >0)
+ if (nIndexes > 0)
+ {
+ for (uint32 i = 0; i < nIndexes; ++i)
+ {
+ if ((i % 3) - 1 == 0 && i + 1 < nIndexes)
+ {
+ uint16 tmp = indices[i];
+ indices[i] = indices[i + 1];
+ indices[i + 1] = tmp;
+ }
+ }
fwrite(indices, sizeof(unsigned short), nIndexes, output);
+ }
fwrite("VERT", 4, 1, output);
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
@@ -105,8 +116,12 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
fwrite(&nVertices, sizeof(int), 1, output);
if (nVertices >0)
{
- for(uint32 vpos=0; vpos <nVertices; ++vpos)
- std::swap(vertices[vpos].y, vertices[vpos].z);
+ for (uint32 vpos = 0; vpos < nVertices; ++vpos)
+ {
+ float tmp = vertices[vpos].y;
+ vertices[vpos].y = -vertices[vpos].z;
+ vertices[vpos].z = tmp;
+ }
fwrite(vertices, sizeof(float)*3, nVertices, output);
}