mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 07:31:21 +02:00
No more flickering! Thanks gonana ! ; Tilesetparticles are only rendered/calculated when visible now
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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; }
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user