mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Tools/MeshExtractor: Added some consts
This commit is contained in:
@@ -31,7 +31,7 @@ class GenericCache
|
||||
public:
|
||||
GenericCache() {}
|
||||
|
||||
T* Get(K key)
|
||||
T const* Get(K key)
|
||||
{
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
|
||||
typename std::map<K, T*>::iterator itr = _items.find(key);
|
||||
|
||||
@@ -63,7 +63,7 @@ void ChunkedData::Load( uint32 maxLength, uint32 chunksHint )
|
||||
}
|
||||
}
|
||||
|
||||
int ChunkedData::GetFirstIndex( const std::string& name )
|
||||
int ChunkedData::GetFirstIndex( const std::string& name ) const
|
||||
{
|
||||
for (uint32 i = 0; i < Chunks.size(); ++i)
|
||||
if (Chunks[i]->Name == name)
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
ChunkedData(const std::string &file, uint32 chunksHint = 300);
|
||||
~ChunkedData();
|
||||
|
||||
int GetFirstIndex(const std::string& name);
|
||||
int GetFirstIndex(const std::string& name) const;
|
||||
Chunk* GetChunkByName(const std::string& name);
|
||||
|
||||
void Load(uint32 maxLength, uint32 chunksHint);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "Recast.h"
|
||||
#include "DetourCommon.h"
|
||||
|
||||
void ContinentBuilder::getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax)
|
||||
void ContinentBuilder::getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax) const
|
||||
{
|
||||
// this is for elevation
|
||||
if (verts && vertCount)
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
{}
|
||||
|
||||
void Build();
|
||||
void getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax);
|
||||
void getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax) const;
|
||||
void CalculateTileBounds();
|
||||
float bmin[3];
|
||||
float bmax[3];
|
||||
|
||||
@@ -55,7 +55,7 @@ DBC::~DBC()
|
||||
delete *itr;
|
||||
}
|
||||
|
||||
std::string DBC::GetStringByOffset( int offset )
|
||||
std::string DBC::GetStringByOffset( int offset ) const
|
||||
{
|
||||
int len = 0;
|
||||
for (uint32 i = offset; i < StringBlockSize; i++)
|
||||
@@ -74,10 +74,10 @@ std::string DBC::GetStringByOffset( int offset )
|
||||
return val;
|
||||
}
|
||||
|
||||
Record* DBC::GetRecordById( int id )
|
||||
Record const* DBC::GetRecordById( int id ) const
|
||||
{
|
||||
// we assume Id is index 0
|
||||
for (std::vector<Record*>::iterator itr = Records.begin(); itr != Records.end(); ++itr)
|
||||
for (std::vector<Record*>::const_iterator itr = Records.begin(); itr != Records.end(); ++itr)
|
||||
if ((*itr)->Values[0] == id)
|
||||
return *itr;
|
||||
return NULL;
|
||||
|
||||
@@ -30,9 +30,9 @@ public:
|
||||
DBC(Stream* stream);
|
||||
~DBC();
|
||||
|
||||
std::string GetStringByOffset(int offset);
|
||||
std::string GetStringByOffset(int offset) const;
|
||||
|
||||
Record* GetRecordById(int id);
|
||||
Record const* GetRecordById(int id) const;
|
||||
|
||||
std::string Name;
|
||||
std::vector<Record*> Records;
|
||||
@@ -52,18 +52,18 @@ public:
|
||||
DBC* Source;
|
||||
std::vector<int> Values;
|
||||
|
||||
int operator[](int index)
|
||||
int operator[](int index) const
|
||||
{
|
||||
return Values[index];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T GetValue(int index)
|
||||
T GetValue(int index) const
|
||||
{
|
||||
return *(T*)(&Values[index]);
|
||||
}
|
||||
|
||||
std::string GetString(int index)
|
||||
const std::string GetString(int index) const
|
||||
{
|
||||
return Source->GetStringByOffset(Values[index]);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void DoodadHandler::ProcessInternal(MapChunk* mcnk)
|
||||
continue;
|
||||
|
||||
std::string path = (*_paths)[doodad.MmidIndex];
|
||||
Model* model = Cache->ModelCache.Get(path);
|
||||
Model const* model = Cache->ModelCache.Get(path);
|
||||
if (!model->IsCollidable)
|
||||
continue;
|
||||
|
||||
@@ -100,14 +100,14 @@ void DoodadHandler::ReadDoodadPaths( Chunk* id, Chunk* data )
|
||||
}
|
||||
}
|
||||
|
||||
void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model* model)
|
||||
void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model const* model)
|
||||
{
|
||||
uint32 vertOffset = Vertices.size();
|
||||
|
||||
for (std::vector<Vector3>::iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
|
||||
for (std::vector<Vector3>::const_iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
|
||||
Vertices.push_back(Utils::TransformDoodadVertex(def, *itr)); // Vertices have to be converted based on the information from the DoodadDefinition struct
|
||||
|
||||
for (std::vector<Triangle<uint16> >::iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
|
||||
for (std::vector<Triangle<uint16> >::const_iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
|
||||
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_DOODAD, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
bool IsSane() { return _definitions && _paths; }
|
||||
bool IsSane() const { return _definitions && _paths; }
|
||||
|
||||
|
||||
protected:
|
||||
@@ -68,7 +68,7 @@ protected:
|
||||
private:
|
||||
void ReadDoodadDefinitions(Chunk* chunk);
|
||||
void ReadDoodadPaths(Chunk* id, Chunk* data);
|
||||
void InsertModelGeometry(const DoodadDefinition& def, Model* model);
|
||||
void InsertModelGeometry(const DoodadDefinition& def, Model const* model);
|
||||
std::set<uint32> _drawn;
|
||||
std::vector<DoodadDefinition>* _definitions;
|
||||
std::vector<std::string>* _paths;
|
||||
|
||||
@@ -92,12 +92,12 @@ void Geometry::AddData( std::vector<Vector3>& verts, std::vector<Triangle<uint32
|
||||
Triangles.push_back(Triangle<uint32>(itr->Type, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
|
||||
}
|
||||
|
||||
void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
|
||||
void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas ) const
|
||||
{
|
||||
verts = new float[Vertices.size() * 3];
|
||||
for (uint32 i = 0; i < Vertices.size(); ++i)
|
||||
{
|
||||
Vector3& vert = Vertices[i];
|
||||
const Vector3& vert = Vertices[i];
|
||||
verts[(i * 3) + 0] = vert.x;
|
||||
verts[(i * 3) + 1] = vert.y;
|
||||
verts[(i * 3) + 2] = vert.z;
|
||||
@@ -106,7 +106,7 @@ void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
|
||||
tris = new int[Triangles.size() * 3];
|
||||
for (uint32 i = 0; i < Triangles.size(); ++i)
|
||||
{
|
||||
Triangle<uint32>& tri = Triangles[i];
|
||||
const Triangle<uint32>& tri = Triangles[i];
|
||||
tris[(i * 3) + 0] = (int)tri.V0;
|
||||
tris[(i * 3) + 1] = (int)tri.V1;
|
||||
tris[(i * 3) + 2] = (int)tri.V2;
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
void CalculateMinMaxHeight(float& min, float& max);
|
||||
void AddData(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris);
|
||||
void AddAdt(ADT* adt);
|
||||
void GetRawData(float*& verts, int*& tris, uint8*& areas);
|
||||
void GetRawData(float*& verts, int*& tris, uint8*& areas) const;
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "LiquidHandler.h"
|
||||
#include "Utils.h"
|
||||
#include "DBC.h"
|
||||
#include "MPQManager.h"
|
||||
|
||||
LiquidHandler::LiquidHandler( ADT* adt ) : Source(adt)
|
||||
{
|
||||
@@ -58,6 +60,11 @@ void LiquidHandler::HandleNewLiquid()
|
||||
stream->Seek(chunk->Offset + h.OffsetInformation, SEEK_SET);
|
||||
H2OInformation information = H2OInformation::Read(stream);
|
||||
|
||||
// Load the LiquidTypes DBC
|
||||
DBC const* liquidTypes = MPQHandler->GetDBC("LiquidTypes");
|
||||
Record const* liquid = liquidTypes->GetRecordById(information.LiquidType);
|
||||
ASSERT(liquid);
|
||||
|
||||
// This pointer will be passed to the MCNKLiquidData constructor, from that point on, it is the job of MCNKLiquidData's destructor to release it.
|
||||
float** heights = new float*[9];
|
||||
for (int j = 0; j < 9; ++j)
|
||||
@@ -65,9 +72,9 @@ void LiquidHandler::HandleNewLiquid()
|
||||
heights[j] = new float[9];
|
||||
memset(heights[j], 0, sizeof(float) * 9);
|
||||
}
|
||||
|
||||
|
||||
H2ORenderMask renderMask;
|
||||
if (information.LiquidType != 2 && information.LiquidType != 6 && information.LiquidType != 10) // Skip Ocean, Slow Ocean and Fast Ocean
|
||||
if (liquid->GetValue<uint32>(3) != 1) // Read the liquid type and skip Ocean, Slow Ocean and Fast Ocean
|
||||
{
|
||||
stream->Seek(chunk->Offset + h.OffsetRender, SEEK_SET);
|
||||
renderMask = H2ORenderMask::Read(stream);
|
||||
@@ -120,25 +127,16 @@ void LiquidHandler::HandleNewLiquid()
|
||||
|
||||
// Define the liquid type
|
||||
Constants::TriangleType type = Constants::TRIANGLE_TYPE_UNKNOWN;
|
||||
switch (information.LiquidType)
|
||||
switch (liquid->GetValue<uint32>(3))
|
||||
{
|
||||
case 1: // Water
|
||||
case 2: // Ocean
|
||||
case 5: // Slow Water
|
||||
case 6: // Slow Ocean
|
||||
case 9: // Fast Water
|
||||
case 10: // Fast Ocean
|
||||
default:
|
||||
case 0: // Water
|
||||
case 1: // Ocean
|
||||
type = Constants::TRIANGLE_TYPE_WATER;
|
||||
break;
|
||||
case 3: // Magma
|
||||
case 7: // Slow Magma
|
||||
case 11: // Fast Magma
|
||||
case 2: // Magma
|
||||
type = Constants::TRIANGLE_TYPE_MAGMA;
|
||||
break;
|
||||
case 4: // Slime
|
||||
case 8: // Slow Slime
|
||||
case 12: // Fast Slime
|
||||
case 3: // Slime
|
||||
type = Constants::TRIANGLE_TYPE_SLIME;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -83,17 +83,17 @@ public:
|
||||
~MPQFile() { close(); }
|
||||
size_t Read(void* dest, size_t bytes);
|
||||
Stream* GetFileStream();
|
||||
size_t getSize() { return size; }
|
||||
size_t getPos() { return pointer; }
|
||||
size_t getSize() const { return size; }
|
||||
size_t getPos() const { return pointer; }
|
||||
char* getBuffer() { return buffer; }
|
||||
char* getPointer() { return buffer + pointer; }
|
||||
bool isEof() { return eof; }
|
||||
bool isEof() const { return eof; }
|
||||
void seek(int offset);
|
||||
void seekRelative(int offset);
|
||||
void close();
|
||||
};
|
||||
|
||||
inline void flipcc(char *fcc)
|
||||
inline void flipcc(char* fcc)
|
||||
{
|
||||
char t;
|
||||
t=fcc[0];
|
||||
|
||||
@@ -109,10 +109,18 @@ Stream* MPQManager::GetFile(const std::string& path )
|
||||
return file.GetFileStream();
|
||||
}
|
||||
|
||||
DBC* MPQManager::GetDBC(const std::string& name )
|
||||
DBC const* MPQManager::GetDBC(const std::string& name )
|
||||
{
|
||||
std::map<std::string, DBC*>::const_iterator itr = LoadedDBCs.find(name);
|
||||
if (itr != LoadedDBCs.end())
|
||||
return itr->second;
|
||||
|
||||
std::string path = "DBFilesClient\\" + name + ".dbc";
|
||||
return new DBC(GetFile(path));
|
||||
DBC* dbc = new DBC(GetFile(path));
|
||||
|
||||
LoadedDBCs[name] = dbc;
|
||||
|
||||
return dbc;
|
||||
}
|
||||
|
||||
Stream* MPQManager::GetFileFromLocale( const std::string& path, uint32 locale )
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
Stream* GetFileFrom(const std::string& path, MPQArchive* file);
|
||||
Stream* GetFileFromLocale(const std::string& path, uint32 locale);
|
||||
|
||||
DBC* GetDBC(const std::string& name);
|
||||
DBC const* GetDBC(const std::string& name);
|
||||
std::vector<std::string> GetAllFiles(std::string extension);
|
||||
|
||||
std::deque<MPQArchive*> Archives;
|
||||
@@ -51,6 +51,7 @@ protected:
|
||||
void InitializeDBC();
|
||||
private:
|
||||
ACE_Thread_Mutex mutex;
|
||||
std::map<std::string, DBC*> LoadedDBCs;
|
||||
};
|
||||
|
||||
extern MPQManager* MPQHandler;
|
||||
|
||||
@@ -61,9 +61,9 @@ void ExtractMMaps(std::set<uint32>& mapIds, uint32 threads)
|
||||
std::string basePath = "mmaps/";
|
||||
Utils::CreateDir(basePath);
|
||||
|
||||
DBC* dbc = MPQHandler->GetDBC("Map");
|
||||
DBC const* dbc = MPQHandler->GetDBC("Map");
|
||||
printf("Map.dbc contains " SIZEFMTD " rows.\n", dbc->Records.size());
|
||||
for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
|
||||
for (std::vector<Record*>::const_iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
|
||||
{
|
||||
uint32 mapId = (*itr)->Values[0];
|
||||
|
||||
@@ -146,8 +146,8 @@ void ExtractGameobjectModels()
|
||||
return;
|
||||
}
|
||||
|
||||
DBC* dbc = MPQHandler->GetDBC("GameObjectDisplayInfo");
|
||||
for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
|
||||
DBC const* dbc = MPQHandler->GetDBC("GameObjectDisplayInfo");
|
||||
for (std::vector<Record*>::const_iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
|
||||
{
|
||||
std::string path = (*itr)->GetString(1);
|
||||
std::string fileName = Utils::GetPlainName(path.c_str());
|
||||
|
||||
@@ -41,12 +41,12 @@ public:
|
||||
|
||||
void Seek(uint32 position, uint32 type);
|
||||
|
||||
uint32 GetSize()
|
||||
uint32 GetSize() const
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
uint32 GetPos()
|
||||
uint32 GetPos() const
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ TileBuilder::TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x,
|
||||
Context = new rcContext;
|
||||
}
|
||||
|
||||
void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshParams& /*navMeshParams*/ )
|
||||
void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshParams& /*navMeshParams*/ ) const
|
||||
{
|
||||
bmin = new float[3];
|
||||
bmax = new float[3];
|
||||
@@ -81,7 +81,7 @@ void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshPara
|
||||
bmax[2] = Constants::Origin[2] /*navMeshParams.orig[2]*/ + (Constants::TileSize * (Y + 1));
|
||||
}
|
||||
|
||||
void TileBuilder::AddGeometry(WorldModelRoot* root, const WorldModelDefinition& def)
|
||||
void TileBuilder::AddGeometry(WorldModelRoot const* root, const WorldModelDefinition& def)
|
||||
{
|
||||
_Geometry = new Geometry();
|
||||
_Geometry->Transform = true;
|
||||
@@ -226,7 +226,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
adt->Read();
|
||||
_Geometry->AddAdt(adt);
|
||||
delete adt;
|
||||
|
||||
|
||||
if (_Geometry->Vertices.empty() && _Geometry->Triangles.empty())
|
||||
return NULL;
|
||||
|
||||
@@ -387,7 +387,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TileBuilder::OutputDebugVertices()
|
||||
void TileBuilder::OutputDebugVertices() const
|
||||
{
|
||||
if (Constants::Debug)
|
||||
{
|
||||
|
||||
@@ -32,11 +32,11 @@ public:
|
||||
TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x, int y, uint32 mapId);
|
||||
~TileBuilder();
|
||||
|
||||
void CalculateTileBounds(float*& bmin, float*& bmax, dtNavMeshParams& navMeshParams);
|
||||
void CalculateTileBounds(float*& bmin, float*& bmax, dtNavMeshParams& navMeshParams) const;
|
||||
uint8* BuildTiled(dtNavMeshParams& navMeshParams);
|
||||
uint8* BuildInstance(dtNavMeshParams& navMeshParams);
|
||||
void AddGeometry(WorldModelRoot* root, const WorldModelDefinition& def);
|
||||
void OutputDebugVertices();
|
||||
void AddGeometry(WorldModelRoot const* root, const WorldModelDefinition& def);
|
||||
void OutputDebugVertices() const;
|
||||
std::string World;
|
||||
int X;
|
||||
int Y;
|
||||
|
||||
@@ -92,7 +92,7 @@ Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool t
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector3 Utils::TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& /*root*/, Vector3& vec, bool translate )
|
||||
Vector3 Utils::TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& /*root*/, const Vector3& vec, bool translate)
|
||||
{
|
||||
G3D::Quat quat = G3D::Quat(-inst.QuatY, inst.QuatZ, -inst.QuatX, inst.QuatW);
|
||||
|
||||
@@ -374,7 +374,7 @@ void LiquidData::Read(Stream* stream, LiquidHeader& header)
|
||||
{
|
||||
for (uint32 x = 0; x < header.CountXVertices; x++)
|
||||
{
|
||||
stream->Read<uint32>(); // Dummy value
|
||||
stream->Skip<uint32>();
|
||||
HeightMap[x][y] = stream->Read<float>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public:
|
||||
uint32 CountXVertices;
|
||||
uint32 Width;
|
||||
|
||||
bool ShouldRender(int x, int y)
|
||||
bool ShouldRender(int x, int y) const
|
||||
{
|
||||
return RenderFlags[x][y] != 0x0F;
|
||||
}
|
||||
@@ -414,7 +414,7 @@ public:
|
||||
static char* GetPlainName(const char* FileName);
|
||||
static Vector3 TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool translate = true);
|
||||
static Vector3 VectorTransform(const Vector3& vec, const G3D::Matrix4& matrix, bool normal = false);
|
||||
static Vector3 TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, Vector3& vec, bool translate = true);
|
||||
static Vector3 TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, const Vector3& vec, bool translate = true);
|
||||
static void InitializeMmapTileHeader(MmapTileHeader& header);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -64,9 +64,9 @@ void WDT::ReadTileTable()
|
||||
}
|
||||
}
|
||||
|
||||
bool WDT::HasTile( int x, int y )
|
||||
bool WDT::HasTile( int x, int y ) const
|
||||
{
|
||||
for (std::vector<TilePos>::iterator itr = TileTable.begin(); itr != TileTable.end(); ++itr)
|
||||
for (std::vector<TilePos>::const_iterator itr = TileTable.begin(); itr != TileTable.end(); ++itr)
|
||||
if (itr->X == x && itr->Y == y)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
bool IsValid;
|
||||
std::string ModelFile;
|
||||
WorldModelDefinition ModelDefinition;
|
||||
WorldModelRoot* Model;
|
||||
bool HasTile(int x, int y);
|
||||
WorldModelRoot const* Model;
|
||||
bool HasTile(int x, int y) const;
|
||||
private:
|
||||
void ReadGlobalModel();
|
||||
void ReadTileTable();
|
||||
|
||||
@@ -75,7 +75,7 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
|
||||
continue;
|
||||
|
||||
std::string path = (*_paths)[wmo.MwidIndex];
|
||||
WorldModelRoot* model = Cache->WorldModelCache.Get(path);
|
||||
WorldModelRoot const* model = Cache->WorldModelCache.Get(path);
|
||||
|
||||
Vertices.reserve(1000);
|
||||
Triangles.reserve(1000);
|
||||
@@ -86,13 +86,13 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
|
||||
stream->Seek(mcnk->Source->Offset, SEEK_SET);
|
||||
}
|
||||
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate )
|
||||
void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot const* root, bool translate )
|
||||
{
|
||||
for (std::vector<WorldModelGroup*>::iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
|
||||
for (std::vector<WorldModelGroup*>::const_iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
|
||||
{
|
||||
WorldModelGroup* group = *groupItr;
|
||||
WorldModelGroup const* group = *groupItr;
|
||||
uint32 vertOffset = verts.size();
|
||||
for (std::vector<Vector3>::iterator itr2 = group->Vertices.begin(); itr2 != group->Vertices.end(); ++itr2)
|
||||
for (std::vector<Vector3>::const_iterator itr2 = group->Vertices.begin(); itr2 != group->Vertices.end(); ++itr2)
|
||||
{
|
||||
Vector3 v = Utils::TransformDoodadVertex(def, *itr2, translate);
|
||||
// If translate is false, then we were called directly from the TileBuilder to add data to it's _Geometry member, hence, we have to manually convert the vertices to Recast format.
|
||||
@@ -123,34 +123,33 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::v
|
||||
|
||||
for (std::vector<DoodadInstance>::iterator instance = instances.begin(); instance != instances.end(); ++instance)
|
||||
{
|
||||
Model* model = Cache->ModelCache.Get(instance->File);
|
||||
Model const* model = Cache->ModelCache.Get(instance->File);
|
||||
|
||||
if (!model->IsCollidable)
|
||||
continue;
|
||||
int vertOffset = verts.size();
|
||||
for (std::vector<Vector3>::iterator itr2 = model->Vertices.begin(); itr2 != model->Vertices.end(); ++itr2)
|
||||
for (std::vector<Vector3>::const_iterator itr2 = model->Vertices.begin(); itr2 != model->Vertices.end(); ++itr2)
|
||||
{
|
||||
Vector3 v = Utils::TransformDoodadVertex(def, Utils::TransformWmoDoodad(*instance, def, *itr2, false), translate);
|
||||
verts.push_back(translate ? v : Utils::ToRecast(v));
|
||||
}
|
||||
for (std::vector<Triangle<uint16> >::iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
|
||||
for (std::vector<Triangle<uint16> >::const_iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
|
||||
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WMO, itr2->V0 + vertOffset, itr2->V1 + vertOffset, itr2->V2 + vertOffset));
|
||||
}
|
||||
|
||||
for (std::vector<WorldModelGroup*>::iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
|
||||
for (std::vector<WorldModelGroup*>::const_iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
|
||||
{
|
||||
WorldModelGroup* group = *groupItr;
|
||||
WorldModelGroup const* group = *groupItr;
|
||||
if (!group->HasLiquidData)
|
||||
continue;
|
||||
|
||||
const LiquidHeader& liquidHeader = group->LiquidDataHeader;
|
||||
LiquidData& liquidDataGeometry = group->LiquidDataGeometry;
|
||||
const LiquidData& liquidDataGeometry = group->LiquidDataGeometry;
|
||||
|
||||
for (uint32 y = 0; y < liquidHeader.Height; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < liquidHeader.Width; x++)
|
||||
{
|
||||
|
||||
if (!liquidDataGeometry.ShouldRender(x, y))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
|
||||
std::vector<Vector3> Vertices;
|
||||
std::vector<Triangle<uint32> > Triangles;
|
||||
bool IsSane() { return _definitions && _paths; }
|
||||
static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate = true);
|
||||
bool IsSane() const { return _definitions && _paths; }
|
||||
static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot const* root, bool translate = true);
|
||||
protected:
|
||||
void ProcessInternal(MapChunk* data);
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user