Tools/MeshExtractor: Fixed a few leaks and added the liquid vertices to the output data.

This commit is contained in:
Subv
2013-12-31 16:22:24 -05:00
parent 31bd3bab3f
commit 7b9dbfb1db
6 changed files with 38 additions and 4 deletions

View File

@@ -33,6 +33,11 @@ ADT::ADT( std::string file, int x, int y ) : ObjectData(NULL), Data(NULL), HasOb
ADT::~ADT()
{
// Temporarily delete the underlying streams, they are guaranteed to be different
// @TODO: Remove this code once the ChunkedData destructor properly releases _Stream
delete ObjectData->_Stream;
delete Data->_Stream;
delete ObjectData;
delete Data;

View File

@@ -85,7 +85,7 @@ ChunkedData::~ChunkedData()
delete *itr;
Chunks.clear();
/* WorldModelGroup Data and SubData share the same _Stream so it's deleted twice and it crahes
/* WorldModelGroup Data and SubData share the same _Stream so it's deleted twice and it crashes
if (_Stream)
delete _Stream;*/
}

View File

@@ -20,6 +20,7 @@
#include "ADT.h"
#include "WorldModelHandler.h"
#include "DoodadHandler.h"
#include "LiquidHandler.h"
#include <limits.h>
Geometry::Geometry() : Transform(false)
@@ -142,5 +143,8 @@ void Geometry::AddAdt( ADT* adt )
if (!adt->_WorldModelHandler->Triangles.empty())
AddData(adt->_WorldModelHandler->Vertices, adt->_WorldModelHandler->Triangles);
if (!adt->_LiquidHandler->Triangles.empty())
AddData(adt->_LiquidHandler->Vertices, adt->_LiquidHandler->Triangles);
}

View File

@@ -21,6 +21,7 @@
LiquidHandler::LiquidHandler( ADT* adt ) : Source(adt)
{
HandleNewLiquid();
HandleOldLiquid();
}
LiquidHandler::~LiquidHandler()
@@ -66,7 +67,7 @@ void LiquidHandler::HandleNewLiquid()
}
H2ORenderMask renderMask;
if (information.LiquidType != 2)
if (information.LiquidType != 2 && information.LiquidType != 6 && information.LiquidType != 10) // Skip Ocean, Slow Ocean and Fast Ocean
{
stream->Seek(chunk->Offset + h.OffsetRender, SEEK_SET);
renderMask = H2ORenderMask::Read(stream);
@@ -123,13 +124,21 @@ void LiquidHandler::HandleNewLiquid()
{
case 1: // Water
case 2: // Ocean
case 5: // Slow Water
case 6: // Slow Ocean
case 9: // Fast Water
case 10: // Fast Ocean
default:
type = Constants::TRIANGLE_TYPE_WATER;
break;
case 3:
case 3: // Magma
case 7: // Slow Magma
case 11: // Fast Magma
type = Constants::TRIANGLE_TYPE_MAGMA;
break;
case 4:
case 4: // Slime
case 8: // Slow Slime
case 12: // Fast Slime
type = Constants::TRIANGLE_TYPE_SLIME;
break;
}
@@ -140,3 +149,14 @@ void LiquidHandler::HandleNewLiquid()
}
}
}
void LiquidHandler::HandleOldLiquid()
{
for (uint32 i = 0; i < 256; ++i)
{
MapChunk* mapChunk = Source->MapChunks[i];
if (!mapChunk->Header.OffsetMCLQ || mapChunk->Header.SizeMCLQ <= 8)
continue;
printf("Found old liquid");
}
}

View File

@@ -35,5 +35,6 @@ public:
std::vector<MCNKLiquidData*> MCNKData;
private:
void HandleNewLiquid();
void HandleOldLiquid();
};
#endif

View File

@@ -39,6 +39,10 @@ WorldModelGroup::WorldModelGroup(Stream* stream, std::string path, int groupInde
WorldModelGroup::~WorldModelGroup()
{
// Temporarily delete the underlying stream, it is the same pointer for both Data and SubData.
// @TODO: Remove this code once the ChunkedData destructor properly releases _Stream
delete Data->_Stream;
delete Data;
delete SubData;
delete[] MOBA;