diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index f1d97dd9c..53b615455 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -2934,7 +2934,7 @@ void Renderer::renderUnitsFast() { assertGl(); bool modelRenderStarted = false; - bool modelRenderFactionStarted = false; + //bool modelRenderFactionStarted = false; if(useQuadCache == true) { VisibleQuadContainerCache &qCache = getQuadCache(); @@ -2977,10 +2977,10 @@ void Renderer::renderUnitsFast() { glPopName(); } - if(modelRenderFactionStarted == true) { + //if(modelRenderFactionStarted == true) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] calling glPopName() for lastFactionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,lastFactionIndex); - glPopName(); - } + //glPopName(); + //} if(modelRenderStarted == true) { modelRenderer->end(); @@ -3717,12 +3717,19 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { } } +void Renderer::setQuadCacheDirty(bool value) { + quadCache.cacheIsDirty = value; +} + VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame, bool forceNew) { //forceNew = true; if(game != NULL && game->getWorld() != NULL) { const World *world= game->getWorld(); + if(quadCache.cacheIsDirty == true) { + forceNew = true; + } if(forceNew == true || (updateOnDirtyFrame == true && (world->getFrameCount() != quadCache.cacheFrame || @@ -3796,6 +3803,7 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame, } } quadCache.cacheFrame = world->getFrameCount(); + quadCache.cacheIsDirty = false; quadCache.lastVisibleQuad = visibleQuad; } } diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index f414fe8ca..9246bc817 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -79,6 +79,7 @@ protected: void CopyAll(const VisibleQuadContainerCache &obj) { cacheFrame = obj.cacheFrame; + cacheIsDirty = obj.cacheIsDirty; visibleObjectList = obj.visibleObjectList; visibleUnitList = obj.visibleUnitList; visibleQuadUnitList = obj.visibleQuadUnitList; @@ -92,6 +93,7 @@ public: VisibleQuadContainerCache() { cacheFrame = 0; + cacheIsDirty = false; clearCacheData(); } VisibleQuadContainerCache(const VisibleQuadContainerCache &obj) { @@ -118,6 +120,7 @@ public: int cacheFrame; Quad2i lastVisibleQuad; + bool cacheIsDirty; std::vector visibleObjectList; std::vector visibleQuadUnitList; std::vector visibleUnitList; @@ -369,6 +372,7 @@ public: int getLastRenderFps() const { return lastRenderFps;} VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false); + void setQuadCacheDirty(bool value); private: //private misc diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index 2b78a63a2..0e59b68c9 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -19,6 +19,7 @@ #include "resource.h" #include "util.h" #include "randomgen.h" +#include "renderer.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -46,7 +47,10 @@ Object::Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos) { } Object::~Object(){ - delete resource; + delete resource; + + Renderer &renderer= Renderer::getInstance(); + renderer.setQuadCacheDirty(true); } const Model *Object::getModel() const{