From f681b309a9b5be68a353a64d63b7a2d0251531b2 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 22 Jul 2012 00:04:44 +0000 Subject: [PATCH] - turned off the interpolation cache which was taking too much memory. Please test this to see if performance is affected, this should REALLY help with memory usage. --- source/g3d_viewer/main.cpp | 5 +++++ source/shared_lib/include/graphics/interpolation.h | 4 +++- source/shared_lib/sources/graphics/interpolation.cpp | 4 ++-- source/shared_lib/sources/graphics/model.cpp | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 6f27c5cb..ef8255aa 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -25,6 +25,8 @@ #include "game_constants.h" #include #include +//#include "interpolation.h" + #ifndef WIN32 #include #endif @@ -62,6 +64,7 @@ const string g3dviewerVersionString= "v1.3.6"; string fileFormat = "png"; namespace Glest { namespace Game { + string getGameReadWritePath(string lookupKey) { string path = ""; if(path == "" && getenv("GLESTHOME") != NULL) { @@ -2035,6 +2038,8 @@ END_EVENT_TABLE() // =============================================== bool App::OnInit() { + //InterpolationData::setEnableCache(false); + SystemFlags::VERBOSE_MODE_ENABLED = false; //Renderer::windowW = 1920; //Renderer::windowH = 1440; diff --git a/source/shared_lib/include/graphics/interpolation.h b/source/shared_lib/include/graphics/interpolation.h index 1f1559e9..92a6448d 100644 --- a/source/shared_lib/include/graphics/interpolation.h +++ b/source/shared_lib/include/graphics/interpolation.h @@ -35,12 +35,14 @@ private: std::map > cacheVertices; std::map > cacheNormals; - bool enableCache; + static bool enableCache; public: InterpolationData(const Mesh *mesh); ~InterpolationData(); + static void setEnableCache(bool enabled) { enableCache = enabled; } + const Vec3f *getVertices() const {return vertices==NULL? mesh->getVertices(): vertices;} const Vec3f *getNormals() const {return normals==NULL? mesh->getNormals(): normals;} diff --git a/source/shared_lib/sources/graphics/interpolation.cpp b/source/shared_lib/sources/graphics/interpolation.cpp index 043daeb8..b1976afe 100644 --- a/source/shared_lib/sources/graphics/interpolation.cpp +++ b/source/shared_lib/sources/graphics/interpolation.cpp @@ -30,6 +30,8 @@ namespace Shared{ namespace Graphics{ // class InterpolationData // ===================================================== +bool InterpolationData::enableCache = false; + InterpolationData::InterpolationData(const Mesh *mesh) { assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false); @@ -43,8 +45,6 @@ InterpolationData::InterpolationData(const Mesh *mesh) { normals= new Vec3f[mesh->getVertexCount()]; } - enableCache = true; - cacheVertices.clear(); cacheNormals.clear(); } diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 4ce360f2..7d86fd59 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -117,6 +117,9 @@ void Mesh::end() { // ========================== shadows & interpolation ========================= void Mesh::buildInterpolationData(){ + if(interpolationData != NULL) { + printf("**WARNING possible memory leak [Mesh::buildInterpolationData()]\n"); + } interpolationData= new InterpolationData(this); }