diff options
author | Sebastian Valle <s.v.h21@hotmail.com> | 2013-10-06 13:47:22 -0500 |
---|---|---|
committer | Sebastian Valle <s.v.h21@hotmail.com> | 2013-10-06 13:47:22 -0500 |
commit | 58912635a7a24d53632da35bbae8c6d15e217b41 (patch) | |
tree | 055aa0077322bdc0ff58a8711e5ed9deb7386068 | |
parent | 79ad827895acc0439336a48055164c4242a89a90 (diff) |
Tools/MeshExtractor: Fixed a few errors under GCC and changed a bit how the GenericCache class works.
-rw-r--r-- | src/tools/mesh_extractor/Cache.h | 16 | ||||
-rw-r--r-- | src/tools/mesh_extractor/DoodadHandler.cpp | 5 | ||||
-rw-r--r-- | src/tools/mesh_extractor/Geometry.cpp | 4 | ||||
-rw-r--r-- | src/tools/mesh_extractor/Utils.cpp | 2 | ||||
-rw-r--r-- | src/tools/mesh_extractor/Utils.h | 2 | ||||
-rw-r--r-- | src/tools/mesh_extractor/WorldModelHandler.cpp | 10 |
6 files changed, 14 insertions, 25 deletions
diff --git a/src/tools/mesh_extractor/Cache.h b/src/tools/mesh_extractor/Cache.h index 9b3e046fe1e..6c84324d7fb 100644 --- a/src/tools/mesh_extractor/Cache.h +++ b/src/tools/mesh_extractor/Cache.h @@ -14,15 +14,14 @@ class GenericCache public: GenericCache() {} - static const uint32 FlushLimit = 300; // We can't get too close to filling up all the memory, and we have to be wary of the maximum number of open streams. + static const uint32 FlushLimit = 300; void Insert(K key, T* val) { ACE_GUARD(ACE_Thread_Mutex, g, mutex); - - if (_items.size() > FlushLimit) - Clear(); - _items[key] = val; + if (_items.find(key) != _items.end()) // Make sure that the object isn't in the cache already + delete _items[key]; // Delete the previous item + _items[key] = val; // Reassign it } T* Get(K key) @@ -31,7 +30,12 @@ public: typename std::map<K, T*>::iterator itr = _items.find(key); if (itr != _items.end()) return itr->second; - return NULL; + else + { + T* t = new T(key); // Create the object + _items[key] = t; + return t; + } } void Clear() diff --git a/src/tools/mesh_extractor/DoodadHandler.cpp b/src/tools/mesh_extractor/DoodadHandler.cpp index 4619f418e55..506f3192344 100644 --- a/src/tools/mesh_extractor/DoodadHandler.cpp +++ b/src/tools/mesh_extractor/DoodadHandler.cpp @@ -40,11 +40,6 @@ void DoodadHandler::ProcessInternal(MapChunk* mcnk) std::string path = (*_paths)[doodad.MmidIndex]; Model* model = Cache->ModelCache.Get(path); - if (!model) - { - model = new Model(path); - Cache->ModelCache.Insert(path, model); - } if (!model->IsCollidable) continue; diff --git a/src/tools/mesh_extractor/Geometry.cpp b/src/tools/mesh_extractor/Geometry.cpp index df828dcd573..49be7ef71e7 100644 --- a/src/tools/mesh_extractor/Geometry.cpp +++ b/src/tools/mesh_extractor/Geometry.cpp @@ -17,7 +17,7 @@ void Geometry::CalculateBoundingBox( float*& min, float*& max ) max = new float[3]; for (int i = 0; i < 3; ++i) { - max[i] = std::numeric_limits<float>::lowest(); + max[i] = -FLT_MAX; min[i] = std::numeric_limits<float>::max(); } @@ -43,7 +43,7 @@ void Geometry::CalculateBoundingBox( float*& min, float*& max ) void Geometry::CalculateMinMaxHeight( float& min, float& max ) { min = std::numeric_limits<float>::max(); - max = std::numeric_limits<float>::lowest(); + max = -FLT_MAX; for (std::vector<Vector3>::iterator itr = Vertices.begin(); itr != Vertices.end(); ++itr) { diff --git a/src/tools/mesh_extractor/Utils.cpp b/src/tools/mesh_extractor/Utils.cpp index 834303d164f..d533c37f9f7 100644 --- a/src/tools/mesh_extractor/Utils.cpp +++ b/src/tools/mesh_extractor/Utils.cpp @@ -63,7 +63,7 @@ std::string Utils::FixModelPath(const std::string& path ) return Utils::GetPathBase(path) + ".M2"; } -Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3& vec, bool translate) +Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool translate) { // Sources of information: /// http://www.pxr.dk/wowdev/wiki/index.php?title=ADT/v18&oldid=3715 diff --git a/src/tools/mesh_extractor/Utils.h b/src/tools/mesh_extractor/Utils.h index 617da2b2244..45cfc6cfd4b 100644 --- a/src/tools/mesh_extractor/Utils.h +++ b/src/tools/mesh_extractor/Utils.h @@ -383,7 +383,7 @@ public: static Vector3 ToWoWCoords(const Vector3& vec); static std::string GetExtension( std::string path); static char* GetPlainName(const char* FileName); - static Vector3 TransformDoodadVertex(const IDefinition& def, Vector3& vec, bool translate = true); + 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); }; diff --git a/src/tools/mesh_extractor/WorldModelHandler.cpp b/src/tools/mesh_extractor/WorldModelHandler.cpp index d9f9cef2b96..bf54609ca5b 100644 --- a/src/tools/mesh_extractor/WorldModelHandler.cpp +++ b/src/tools/mesh_extractor/WorldModelHandler.cpp @@ -59,11 +59,6 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk ) std::string path = (*_paths)[wmo.MwidIndex]; WorldModelRoot* model = Cache->WorldModelCache.Get(path); - if (!model) - { - model = new WorldModelRoot(path); - Cache->WorldModelCache.Insert(path, model); - } Vertices.reserve(1000); Triangles.reserve(1000); @@ -111,11 +106,6 @@ 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); - if (!model) - { - model = new Model(instance->File); - Cache->ModelCache.Insert(instance->File, model); - } if (!model->IsCollidable) continue; |