- bugfixes for rendering (new ini setting toggles new quad cache and is called: UseQuadCache=true)
This commit is contained in:
parent
4d9bc556d6
commit
0783b23e12
|
@ -1549,7 +1549,7 @@ void Game::render2d(){
|
|||
int visibleObjectCount = 0;
|
||||
Map *map= world.getMap();
|
||||
int thisTeamIndex= world.getThisTeamIndex();
|
||||
PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
|
||||
PosQuadIterator pqi(visibleQuad, Map::cellScale);
|
||||
while(pqi.next()){
|
||||
const Vec2i &pos= pqi.getPos();
|
||||
bool isPosVisible = map->isInside(pos.x, pos.y);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -74,75 +74,6 @@ class Object;
|
|||
/// OpenGL renderer, uses the shared library
|
||||
// ===========================================================
|
||||
|
||||
enum RenderEntityState {
|
||||
resNone,
|
||||
resInterpolated,
|
||||
resRendered
|
||||
};
|
||||
|
||||
enum RenderEntityType {
|
||||
retObject,
|
||||
retUnit,
|
||||
retUnitFast
|
||||
};
|
||||
|
||||
class RenderEntity {
|
||||
protected:
|
||||
RenderEntityState state;
|
||||
|
||||
void CopyAll(const RenderEntity &obj) {
|
||||
this->type = obj.type;
|
||||
this->state = obj.state;
|
||||
this->o = obj.o;
|
||||
this->mapPos = obj.mapPos;
|
||||
this->unit = obj.unit;
|
||||
this->teamTexture = obj.teamTexture;;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static bool forceRenderWithIterpolation;
|
||||
|
||||
RenderEntity() {
|
||||
this->type = retObject;
|
||||
this->o = NULL;
|
||||
this->unit = NULL;
|
||||
this->teamTexture = NULL;
|
||||
setState(resNone);
|
||||
}
|
||||
RenderEntity(RenderEntityType type,Object *o, Vec2i mapPos, Unit *unit,const Texture2D *teamTexture=NULL) {
|
||||
this->type = type;
|
||||
this->o = o;
|
||||
this->mapPos = mapPos;
|
||||
this->unit = unit;
|
||||
this->teamTexture = teamTexture;
|
||||
setState(resNone);
|
||||
}
|
||||
RenderEntity(const RenderEntity &obj) {
|
||||
CopyAll(obj);
|
||||
}
|
||||
RenderEntity & operator=(const RenderEntity &obj) {
|
||||
CopyAll(obj);
|
||||
return *this;
|
||||
}
|
||||
bool operator<(const RenderEntity &rhs) const;
|
||||
bool operator()(const RenderEntity &lhs,const RenderEntity &rhs) const;
|
||||
|
||||
RenderEntityType type;
|
||||
Object *o;
|
||||
Vec2i mapPos;
|
||||
Unit *unit;
|
||||
const Texture2D *teamTexture;
|
||||
|
||||
RenderEntityState getState() {
|
||||
return this->state;
|
||||
}
|
||||
void setState(RenderEntityState value) {
|
||||
this->state = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class VisibleQuadContainerCache {
|
||||
protected:
|
||||
|
||||
|
@ -150,7 +81,8 @@ protected:
|
|||
cacheFrame = obj.cacheFrame;
|
||||
visibleObjectList = obj.visibleObjectList;
|
||||
visibleUnitList = obj.visibleUnitList;
|
||||
inVisibleUnitList = obj.inVisibleUnitList;
|
||||
visibleQuadUnitList = obj.visibleQuadUnitList;
|
||||
//inVisibleUnitList = obj.inVisibleUnitList;
|
||||
//visibleCellList = obj.visibleCellList;
|
||||
visibleScaledCellList = obj.visibleScaledCellList;
|
||||
lastVisibleQuad = obj.lastVisibleQuad;
|
||||
|
@ -169,26 +101,27 @@ public:
|
|||
CopyAll(obj);
|
||||
return *this;
|
||||
}
|
||||
//bool operator<(const RenderEntity &rhs) const;
|
||||
//bool operator()(const RenderEntity &lhs,const RenderEntity &rhs) const;
|
||||
|
||||
void clearCacheData() {
|
||||
clearVolatileCacheData();
|
||||
|
||||
visibleObjectList.clear();
|
||||
//visibleCellList.clear();
|
||||
visibleScaledCellList.clear();
|
||||
clearNonVolatileCacheData();
|
||||
}
|
||||
void clearVolatileCacheData() {
|
||||
visibleUnitList.clear();
|
||||
inVisibleUnitList.clear();
|
||||
visibleQuadUnitList.clear();
|
||||
//inVisibleUnitList.clear();
|
||||
}
|
||||
void clearNonVolatileCacheData() {
|
||||
visibleObjectList.clear();
|
||||
visibleScaledCellList.clear();
|
||||
}
|
||||
|
||||
int cacheFrame;
|
||||
Quad2i lastVisibleQuad;
|
||||
std::vector<Object *> visibleObjectList;
|
||||
std::vector<Unit *> visibleQuadUnitList;
|
||||
std::vector<Unit *> visibleUnitList;
|
||||
std::vector<Unit *> inVisibleUnitList;
|
||||
//std::vector<Unit *> inVisibleUnitList;
|
||||
//std::vector<Vec2i> visibleCellList;
|
||||
std::vector<Vec2i> visibleScaledCellList;
|
||||
};
|
||||
|
@ -237,7 +170,7 @@ public:
|
|||
static const float maxLightDist;
|
||||
|
||||
public:
|
||||
enum Shadows{
|
||||
enum Shadows {
|
||||
sDisabled,
|
||||
sProjected,
|
||||
sShadowMapping,
|
||||
|
@ -302,6 +235,7 @@ private:
|
|||
int lastRenderFps;
|
||||
bool shadowsOffDueToMinRender;
|
||||
|
||||
bool useQuadCache;
|
||||
private:
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
@ -381,17 +315,9 @@ public:
|
|||
//complex rendering
|
||||
void renderSurface(const int renderFps, const int worldFrameCount);
|
||||
void renderObjects(const int renderFps, const int worldFrameCount);
|
||||
void renderObject(RenderEntity &entity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount);
|
||||
void renderObject(Object *o,const Vec2i &mapPos,const Vec3f &baseFogColor,const int worldFrameCount);
|
||||
void prepareObjectForRender(RenderEntity &entity);
|
||||
void renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount);
|
||||
|
||||
void renderWater();
|
||||
void renderUnits(const int renderFps, const int worldFrameCount);
|
||||
void prepareUnitForRender(RenderEntity &entity);
|
||||
void renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount);
|
||||
void renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount);
|
||||
void renderUnit(Unit *unit,MeshCallbackTeamColor *meshCallbackTeamColor, const Texture2D *teamTexture, const int worldFrameCount);
|
||||
|
||||
void renderSelectionEffects();
|
||||
void renderWaterEffects();
|
||||
|
@ -442,7 +368,7 @@ public:
|
|||
void setLastRenderFps(int value) { lastRenderFps = value;}
|
||||
int getLastRenderFps() const { return lastRenderFps;}
|
||||
|
||||
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true);
|
||||
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false);
|
||||
|
||||
private:
|
||||
//private misc
|
||||
|
@ -456,12 +382,7 @@ private:
|
|||
|
||||
//selection render
|
||||
void renderObjectsFast();
|
||||
void renderObjectFastList(std::vector<RenderEntity> &vctEntity);
|
||||
void renderUnitsFast();
|
||||
void renderUnitFastList(std::vector<RenderEntity> &vctEntity);
|
||||
void renderUnitFast(RenderEntity &entity);
|
||||
void renderUnitFast(Unit *unit, int x, int y);
|
||||
void prepareUnitFastForRender(RenderEntity &entity);
|
||||
|
||||
//gl requirements
|
||||
void checkGlCaps();
|
||||
|
|
|
@ -864,18 +864,19 @@ bool Gui::isSharedCommandClass(CommandClass commandClass){
|
|||
|
||||
void Gui::computeSelected(bool doubleClick){
|
||||
Selection::UnitContainer units;
|
||||
Renderer::getInstance().computeSelected(units, selectionQuad.getPosDown(), selectionQuad.getPosUp());
|
||||
Renderer::getInstance().computeSelected(units, selectionQuad.getPosDown(),
|
||||
selectionQuad.getPosUp());
|
||||
selectingBuilding= false;
|
||||
activeCommandType= NULL;
|
||||
|
||||
//select all units of the same type if double click
|
||||
if(doubleClick && units.size()==1){
|
||||
if(doubleClick && units.size() == 1) {
|
||||
const Unit *refUnit= units.front();
|
||||
int factionIndex= refUnit->getFactionIndex();
|
||||
for(int i=0; i<world->getFaction(factionIndex)->getUnitCount(); ++i){
|
||||
for(int i=0; i< world->getFaction(factionIndex)->getUnitCount(); ++i) {
|
||||
Unit *unit= world->getFaction(factionIndex)->getUnit(i);
|
||||
if(unit->getPos().dist(refUnit->getPos())<doubleClickSelectionRadius &&
|
||||
unit->getType()==refUnit->getType())
|
||||
if(unit->getPos().dist(refUnit->getPos()) < doubleClickSelectionRadius &&
|
||||
unit->getType() == refUnit->getType())
|
||||
{
|
||||
units.push_back(unit);
|
||||
}
|
||||
|
|
|
@ -449,21 +449,21 @@ void Faction::setResourceBalance(const ResourceType *rt, int balance){
|
|||
assert(false);
|
||||
}
|
||||
|
||||
Unit *Faction::findUnit(int id){
|
||||
Unit *Faction::findUnit(int id) const {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] id = %d\n",__FILE__,__FUNCTION__, __LINE__,id);
|
||||
|
||||
UnitMap::iterator it= unitMap.find(id);
|
||||
UnitMap::const_iterator itFound = unitMap.find(id);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||
|
||||
if(it==unitMap.end()){
|
||||
if(itFound == unitMap.end()) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] it->second = %p\n",__FILE__,__FUNCTION__, __LINE__,it->second);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] it->second->id = %d\n",__FILE__,__FUNCTION__, __LINE__,it->second->getId());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] it->second = %s\n",__FILE__,__FUNCTION__, __LINE__,it->second->toString().c_str());
|
||||
return it->second;
|
||||
return itFound->second;
|
||||
}
|
||||
|
||||
void Faction::addUnit(Unit *unit){
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
bool isAlly(const Faction *faction);
|
||||
|
||||
//other
|
||||
Unit *findUnit(int id);
|
||||
Unit *findUnit(int id) const;
|
||||
void addUnit(Unit *unit);
|
||||
void removeUnit(Unit *unit);
|
||||
void addStore(const UnitType *unitType);
|
||||
|
|
|
@ -906,8 +906,7 @@ const Vec2i &PosCircularIterator::getPos(){
|
|||
// class PosQuadIterator
|
||||
// =====================================================
|
||||
|
||||
PosQuadIterator::PosQuadIterator(const Map *map, const Quad2i &quad, int step){
|
||||
this->map= map;
|
||||
PosQuadIterator::PosQuadIterator(const Quad2i &quad, int step){
|
||||
this->quad= quad;
|
||||
this->boundingRect= quad.computeBoundingRect();
|
||||
this->step= step;
|
||||
|
|
|
@ -271,15 +271,14 @@ public:
|
|||
// class PosQuadIterator
|
||||
// ===============================
|
||||
|
||||
class PosQuadIterator{
|
||||
class PosQuadIterator {
|
||||
private:
|
||||
Quad2i quad;
|
||||
Rect2i boundingRect;
|
||||
const Map *map;
|
||||
Vec2i pos;
|
||||
int step;
|
||||
public:
|
||||
PosQuadIterator(const Map *map, const Quad2i &quad, int step=1);
|
||||
PosQuadIterator(const Quad2i &quad, int step=1);
|
||||
bool next();
|
||||
void skipX();
|
||||
const Vec2i &getPos();
|
||||
|
|
|
@ -29,12 +29,15 @@ namespace Glest{ namespace Game{
|
|||
// class PixmapInfo
|
||||
// =====================================================
|
||||
|
||||
SurfaceInfo::SurfaceInfo(const Pixmap2D *lu, const Pixmap2D *ru, const Pixmap2D *ld, const Pixmap2D *rd) {
|
||||
SurfaceInfo::SurfaceInfo(const Pixmap2D *lu, const Pixmap2D *ru, const Pixmap2D *ld,
|
||||
const Pixmap2D *rd) {
|
||||
this->leftDown= ld;
|
||||
this->leftUp= lu;
|
||||
this->rightDown= rd;
|
||||
this->rightUp= ru;
|
||||
center= NULL;
|
||||
texture=NULL;
|
||||
|
||||
}
|
||||
|
||||
SurfaceInfo::SurfaceInfo(const Pixmap2D *center) {
|
||||
|
@ -43,6 +46,7 @@ SurfaceInfo::SurfaceInfo(const Pixmap2D *center) {
|
|||
this->rightDown= NULL;
|
||||
this->rightUp= NULL;
|
||||
this->center= center;
|
||||
texture=NULL;
|
||||
}
|
||||
|
||||
bool SurfaceInfo::operator==(const SurfaceInfo &si) const {
|
||||
|
|
|
@ -831,7 +831,7 @@ void World::initSplattedTextures(){
|
|||
for(int i=0; i<map.getSurfaceW()-1; ++i){
|
||||
for(int j=0; j<map.getSurfaceH()-1; ++j){
|
||||
Vec2f coord;
|
||||
const Texture2D *texture;
|
||||
const Texture2D *texture=NULL;
|
||||
SurfaceCell *sc00= map.getSurfaceCell(i, j);
|
||||
SurfaceCell *sc10= map.getSurfaceCell(i+1, j);
|
||||
SurfaceCell *sc01= map.getSurfaceCell(i, j+1);
|
||||
|
|
Loading…
Reference in New Issue