aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-12-03 23:30:53 +0100
committerShauren <shauren.trinity@gmail.com>2022-12-03 23:30:53 +0100
commitf22be111ae0a1b2dd51418b0790fab1c8f2f9df7 (patch)
tree9bfdef84f686993b813bd2854d2b1fff058e3477 /src
parent79ca6df27db6edb296eb3c6b2a50670543de713d (diff)
Tools/vmap_extractor: Implemented new MPY2 wmo chunk
Diffstat (limited to 'src')
-rw-r--r--src/tools/vmap4_extractor/wmo.cpp24
-rw-r--r--src/tools/vmap4_extractor/wmo.h4
2 files changed, 17 insertions, 11 deletions
diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp
index fc4265cda59..85f82038da2 100644
--- a/src/tools/vmap4_extractor/wmo.cpp
+++ b/src/tools/vmap4_extractor/wmo.cpp
@@ -204,10 +204,10 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
}
WMOGroup::WMOGroup(const std::string &filename) :
- filename(filename), MOPY(nullptr), MOVX(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr),
+ filename(filename), MPY2(nullptr), MOVX(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr),
hlq(nullptr), LiquEx(nullptr), LiquBytes(nullptr), groupName(0), descGroupName(0), mogpFlags(0),
moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0),
- groupLiquid(0), groupWMOID(0), mopy_size(0), moba_size(0), LiquEx_size(0),
+ groupLiquid(0), groupWMOID(0), moba_size(0), LiquEx_size(0),
nVertices(0), nTriangles(0), liquflags(0)
{
memset(bbcorn1, 0, sizeof(bbcorn1));
@@ -262,10 +262,17 @@ bool WMOGroup::open(WMORoot* rootWMO)
}
else if (!strcmp(fourcc,"MOPY"))
{
- MOPY = new char[size];
- mopy_size = size;
+ MPY2 = std::make_unique<uint16[]>(size);
+ std::unique_ptr<uint8[]> MOPY = std::make_unique<uint8[]>(size);
nTriangles = (int)size / 2;
- f.read(MOPY, size);
+ f.read(MOPY.get(), size);
+ std::copy_n(MOPY.get(), size, MPY2.get());
+ }
+ else if (!strcmp(fourcc,"MPY2"))
+ {
+ MPY2 = std::make_unique<uint16[]>(size / 2);
+ nTriangles = (int)size / 4;
+ f.read(MPY2.get(), size);
}
else if (!strcmp(fourcc,"MOVI"))
{
@@ -440,15 +447,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, bool preciseVectorData)
delete [] MobaEx;
//-------INDX------------------------------------
- //-------MOPY--------
+ //-------MOPY/MPY2--------
std::unique_ptr<uint32[]> MovxEx = std::make_unique<uint32[]>(nTriangles*3); // "worst case" size...
std::unique_ptr<int32[]> IndexRenum = std::make_unique<int32[]>(nVertices);
std::fill_n(IndexRenum.get(), nVertices, -1);
for (int i=0; i<nTriangles; ++i)
{
// Skip no collision triangles
- bool isRenderFace = (MOPY[2 * i] & WMO_MATERIAL_RENDER) && !(MOPY[2 * i] & WMO_MATERIAL_DETAIL);
- bool isCollision = MOPY[2 * i] & WMO_MATERIAL_COLLISION || isRenderFace;
+ bool isRenderFace = (MPY2[2 * i] & WMO_MATERIAL_RENDER) && !(MPY2[2 * i] & WMO_MATERIAL_DETAIL);
+ bool isCollision = MPY2[2 * i] & WMO_MATERIAL_COLLISION || isRenderFace;
if (!isCollision)
continue;
@@ -563,7 +570,6 @@ bool WMOGroup::ShouldSkip(WMORoot const* root) const
WMOGroup::~WMOGroup()
{
- delete [] MOPY;
delete [] MOVT;
delete [] MOBA;
delete hlq;
diff --git a/src/tools/vmap4_extractor/wmo.h b/src/tools/vmap4_extractor/wmo.h
index 5ba69c8b49b..4e149c02422 100644
--- a/src/tools/vmap4_extractor/wmo.h
+++ b/src/tools/vmap4_extractor/wmo.h
@@ -124,7 +124,7 @@ private:
public:
// MOGP
- char* MOPY;
+ std::unique_ptr<uint16[]> MPY2;
std::unique_ptr<uint32[]> MOVX;
float* MOVT;
uint16* MOBA;
@@ -142,7 +142,7 @@ public:
uint16 nBatchB;
uint32 nBatchC, fogIdx, groupLiquid, groupWMOID;
- int mopy_size, moba_size;
+ int moba_size;
int LiquEx_size;
unsigned int nVertices; // number when loaded
int nTriangles; // number when loaded