diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 1e6311fa5..d275c14fc 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -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); } } } diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index efacb6ea5..ae4805758 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -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 diff --git a/source/glest_game/type_instances/object.h b/source/glest_game/type_instances/object.h index 3c44263c0..65920af28 100644 --- a/source/glest_game/type_instances/object.h +++ b/source/glest_game/type_instances/object.h @@ -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; } diff --git a/source/glest_game/types/object_type.cpp b/source/glest_game/types/object_type.cpp index 3f10ab3ed..052cc159b 100644 --- a/source/glest_game/types/object_type.cpp +++ b/source/glest_game/types/object_type.cpp @@ -29,12 +29,11 @@ void ObjectType::init(int modelCount, int objectClass, bool walkable, int height } ObjectType::~ObjectType(){ - - for(int i=0;i