- small improvement for when units and objects are deleted.
This commit is contained in:
parent
f4e6e8ffd7
commit
ab88a2971a
|
@ -3722,6 +3722,38 @@ void Renderer::setQuadCacheDirty(bool value) {
|
|||
quadCache.cacheIsDirty = value;
|
||||
}
|
||||
|
||||
void Renderer::removeObjectFromQuadCache(const Object *o) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
for(int visibleIndex = 0;
|
||||
visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) {
|
||||
Object *currentObj = qCache.visibleObjectList[visibleIndex];
|
||||
if(currentObj == o) {
|
||||
qCache.visibleObjectList.erase(qCache.visibleObjectList.begin() + visibleIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::removeUnitFromQuadCache(const Unit *unit) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
for(int visibleIndex = 0;
|
||||
visibleIndex < qCache.visibleQuadUnitList.size(); ++visibleIndex) {
|
||||
Unit *currentUnit = qCache.visibleQuadUnitList[visibleIndex];
|
||||
if(currentUnit == unit) {
|
||||
qCache.visibleQuadUnitList.erase(qCache.visibleQuadUnitList.begin() + visibleIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(int visibleIndex = 0;
|
||||
visibleIndex < qCache.visibleUnitList.size(); ++visibleIndex) {
|
||||
Unit *currentUnit = qCache.visibleUnitList[visibleIndex];
|
||||
if(currentUnit == unit) {
|
||||
qCache.visibleUnitList.erase(qCache.visibleUnitList.begin() + visibleIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame,
|
||||
bool forceNew) {
|
||||
//forceNew = true;
|
||||
|
|
|
@ -373,6 +373,8 @@ public:
|
|||
|
||||
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false);
|
||||
void setQuadCacheDirty(bool value);
|
||||
void removeObjectFromQuadCache(const Object *o);
|
||||
void removeUnitFromQuadCache(const Unit *unit);
|
||||
|
||||
private:
|
||||
//private misc
|
||||
|
|
|
@ -50,7 +50,8 @@ Object::~Object(){
|
|||
delete resource;
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.setQuadCacheDirty(true);
|
||||
//renderer.setQuadCacheDirty(true);
|
||||
renderer.removeObjectFromQuadCache(this);
|
||||
}
|
||||
|
||||
const Model *Object::getModel() const{
|
||||
|
|
|
@ -286,7 +286,8 @@ Unit::~Unit(){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.setQuadCacheDirty(true);
|
||||
//renderer.setQuadCacheDirty(true);
|
||||
renderer.removeUnitFromQuadCache(this);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue