mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
- added a way to signal the cache is dirty for when resources are deleted.
This commit is contained in:
parent
87e0324dd4
commit
3f393fd37d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Object *> visibleObjectList;
|
||||
std::vector<Unit *> visibleQuadUnitList;
|
||||
std::vector<Unit *> 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
|
||||
|
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user