No more flickering! Thanks gonana ! ; Tilesetparticles are only rendered/calculated when visible now

This commit is contained in:
Titus Tscharntke
2011-03-05 14:34:36 +00:00
parent dcecb1ba8d
commit fefed3e3ce
4 changed files with 25 additions and 7 deletions

View File

@@ -3585,7 +3585,7 @@ void Renderer::renderShadowsToTexture(const int renderFps){
if(shadows == sShadowMapping) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 0.001f);
glPolygonOffset(1.0f, 16.0f);
}
//render 3d
@@ -4753,7 +4753,11 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame,
if(forceNew == true || visibleQuad != quadCache.lastVisibleQuad) {
// Object calculations
const Map *map= world->getMap();
// clear visibility of old objects
for(int visibleIndex = 0;
visibleIndex < quadCache.visibleObjectList.size(); ++visibleIndex){
quadCache.visibleObjectList[visibleIndex]->setVisible(false);
}
quadCache.clearNonVolatileCacheData();
PosQuadIterator pqi(map,visibleQuad, Map::cellScale);
@@ -4778,6 +4782,7 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame,
if(isExplored == true && isVisible == true) {
quadCache.visibleObjectList.push_back(o);
o->setVisible(true);
}
}
}

View File

@@ -46,6 +46,8 @@ Object::Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos) {
if(objectType!=NULL){
variation = random.randRange(0, objectType->getModelCount()-1);
}
visible=false;
}
Object::~Object(){
@@ -75,6 +77,7 @@ void Object::initParticles(){
ups->setPos(this->pos);
ups->setRotation(this->rotation);
ups->setFactionColor(Vec3f(0, 0, 0));
ups->setVisible(false);
this->unitParticleSystems.push_back(ups);
Renderer::getInstance().manageParticleSystem(ups, rsGame);
}
@@ -107,4 +110,12 @@ void Object::setResource(const ResourceType *resourceType, const Vec2i &pos){
resource->init(resourceType, pos);
}
void Object::setVisible( bool visible)
{
this->visible=visible;
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) {
(*it)->setVisible(visible);
}
}
}}//end namespace

View File

@@ -53,6 +53,7 @@ private:
int variation;
int lastRenderFrame;
Vec2i mapPos;
bool visible;
static ObjectStateInterface *stateCallback;
@@ -66,6 +67,7 @@ public:
const ObjectType *getType() const {return objectType;}
Resource *getResource() const {return resource;}
Vec3f getPos() const {return pos;}
bool isVisible() const {return visible;}
const Vec3f & getConstPos() const {return pos;}
float getRotation() {return rotation;}
const Model *getModel() const;
@@ -74,6 +76,7 @@ public:
void setResource(const ResourceType *resourceType, const Vec2i &pos);
void setHeight(float height);
void setVisible(bool visible);
int getLastRenderFrame() const { return lastRenderFrame; }
void setLastRenderFrame(int value) { lastRenderFrame = value; }

View File

@@ -29,12 +29,11 @@ void ObjectType::init(int modelCount, int objectClass, bool walkable, int height
}
ObjectType::~ObjectType(){
for(int i=0;i<particles.size();i++ ){
for(int i= 0; i < particles.size(); i++){
while(!(particles[i].empty())){
delete particles[i].back();
particles[i].pop_back();
}
delete particles[i].back();
particles[i].pop_back();
}
}
//Logger::getInstance().add("ObjectType", true);
}