- 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;
|
int visibleObjectCount = 0;
|
||||||
Map *map= world.getMap();
|
Map *map= world.getMap();
|
||||||
int thisTeamIndex= world.getThisTeamIndex();
|
int thisTeamIndex= world.getThisTeamIndex();
|
||||||
PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
|
PosQuadIterator pqi(visibleQuad, Map::cellScale);
|
||||||
while(pqi.next()){
|
while(pqi.next()){
|
||||||
const Vec2i &pos= pqi.getPos();
|
const Vec2i &pos= pqi.getPos();
|
||||||
bool isPosVisible = map->isInside(pos.x, pos.y);
|
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
|
/// 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 {
|
class VisibleQuadContainerCache {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -150,7 +81,8 @@ protected:
|
||||||
cacheFrame = obj.cacheFrame;
|
cacheFrame = obj.cacheFrame;
|
||||||
visibleObjectList = obj.visibleObjectList;
|
visibleObjectList = obj.visibleObjectList;
|
||||||
visibleUnitList = obj.visibleUnitList;
|
visibleUnitList = obj.visibleUnitList;
|
||||||
inVisibleUnitList = obj.inVisibleUnitList;
|
visibleQuadUnitList = obj.visibleQuadUnitList;
|
||||||
|
//inVisibleUnitList = obj.inVisibleUnitList;
|
||||||
//visibleCellList = obj.visibleCellList;
|
//visibleCellList = obj.visibleCellList;
|
||||||
visibleScaledCellList = obj.visibleScaledCellList;
|
visibleScaledCellList = obj.visibleScaledCellList;
|
||||||
lastVisibleQuad = obj.lastVisibleQuad;
|
lastVisibleQuad = obj.lastVisibleQuad;
|
||||||
|
@ -169,26 +101,27 @@ public:
|
||||||
CopyAll(obj);
|
CopyAll(obj);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
//bool operator<(const RenderEntity &rhs) const;
|
|
||||||
//bool operator()(const RenderEntity &lhs,const RenderEntity &rhs) const;
|
|
||||||
|
|
||||||
void clearCacheData() {
|
void clearCacheData() {
|
||||||
clearVolatileCacheData();
|
clearVolatileCacheData();
|
||||||
|
clearNonVolatileCacheData();
|
||||||
visibleObjectList.clear();
|
|
||||||
//visibleCellList.clear();
|
|
||||||
visibleScaledCellList.clear();
|
|
||||||
}
|
}
|
||||||
void clearVolatileCacheData() {
|
void clearVolatileCacheData() {
|
||||||
visibleUnitList.clear();
|
visibleUnitList.clear();
|
||||||
inVisibleUnitList.clear();
|
visibleQuadUnitList.clear();
|
||||||
|
//inVisibleUnitList.clear();
|
||||||
|
}
|
||||||
|
void clearNonVolatileCacheData() {
|
||||||
|
visibleObjectList.clear();
|
||||||
|
visibleScaledCellList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int cacheFrame;
|
int cacheFrame;
|
||||||
Quad2i lastVisibleQuad;
|
Quad2i lastVisibleQuad;
|
||||||
std::vector<Object *> visibleObjectList;
|
std::vector<Object *> visibleObjectList;
|
||||||
|
std::vector<Unit *> visibleQuadUnitList;
|
||||||
std::vector<Unit *> visibleUnitList;
|
std::vector<Unit *> visibleUnitList;
|
||||||
std::vector<Unit *> inVisibleUnitList;
|
//std::vector<Unit *> inVisibleUnitList;
|
||||||
//std::vector<Vec2i> visibleCellList;
|
//std::vector<Vec2i> visibleCellList;
|
||||||
std::vector<Vec2i> visibleScaledCellList;
|
std::vector<Vec2i> visibleScaledCellList;
|
||||||
};
|
};
|
||||||
|
@ -237,7 +170,7 @@ public:
|
||||||
static const float maxLightDist;
|
static const float maxLightDist;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Shadows{
|
enum Shadows {
|
||||||
sDisabled,
|
sDisabled,
|
||||||
sProjected,
|
sProjected,
|
||||||
sShadowMapping,
|
sShadowMapping,
|
||||||
|
@ -302,6 +235,7 @@ private:
|
||||||
int lastRenderFps;
|
int lastRenderFps;
|
||||||
bool shadowsOffDueToMinRender;
|
bool shadowsOffDueToMinRender;
|
||||||
|
|
||||||
|
bool useQuadCache;
|
||||||
private:
|
private:
|
||||||
Renderer();
|
Renderer();
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
@ -381,17 +315,9 @@ public:
|
||||||
//complex rendering
|
//complex rendering
|
||||||
void renderSurface(const int renderFps, const int worldFrameCount);
|
void renderSurface(const int renderFps, const int worldFrameCount);
|
||||||
void renderObjects(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 renderWater();
|
||||||
void renderUnits(const int renderFps, const int worldFrameCount);
|
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 renderSelectionEffects();
|
||||||
void renderWaterEffects();
|
void renderWaterEffects();
|
||||||
|
@ -442,7 +368,7 @@ public:
|
||||||
void setLastRenderFps(int value) { lastRenderFps = value;}
|
void setLastRenderFps(int value) { lastRenderFps = value;}
|
||||||
int getLastRenderFps() const { return lastRenderFps;}
|
int getLastRenderFps() const { return lastRenderFps;}
|
||||||
|
|
||||||
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true);
|
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//private misc
|
//private misc
|
||||||
|
@ -456,12 +382,7 @@ private:
|
||||||
|
|
||||||
//selection render
|
//selection render
|
||||||
void renderObjectsFast();
|
void renderObjectsFast();
|
||||||
void renderObjectFastList(std::vector<RenderEntity> &vctEntity);
|
|
||||||
void renderUnitsFast();
|
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
|
//gl requirements
|
||||||
void checkGlCaps();
|
void checkGlCaps();
|
||||||
|
|
|
@ -864,18 +864,19 @@ bool Gui::isSharedCommandClass(CommandClass commandClass){
|
||||||
|
|
||||||
void Gui::computeSelected(bool doubleClick){
|
void Gui::computeSelected(bool doubleClick){
|
||||||
Selection::UnitContainer units;
|
Selection::UnitContainer units;
|
||||||
Renderer::getInstance().computeSelected(units, selectionQuad.getPosDown(), selectionQuad.getPosUp());
|
Renderer::getInstance().computeSelected(units, selectionQuad.getPosDown(),
|
||||||
|
selectionQuad.getPosUp());
|
||||||
selectingBuilding= false;
|
selectingBuilding= false;
|
||||||
activeCommandType= NULL;
|
activeCommandType= NULL;
|
||||||
|
|
||||||
//select all units of the same type if double click
|
//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();
|
const Unit *refUnit= units.front();
|
||||||
int factionIndex= refUnit->getFactionIndex();
|
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);
|
Unit *unit= world->getFaction(factionIndex)->getUnit(i);
|
||||||
if(unit->getPos().dist(refUnit->getPos())<doubleClickSelectionRadius &&
|
if(unit->getPos().dist(refUnit->getPos()) < doubleClickSelectionRadius &&
|
||||||
unit->getType()==refUnit->getType())
|
unit->getType() == refUnit->getType())
|
||||||
{
|
{
|
||||||
units.push_back(unit);
|
units.push_back(unit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,21 +449,21 @@ void Faction::setResourceBalance(const ResourceType *rt, int balance){
|
||||||
assert(false);
|
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);
|
//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__);
|
//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__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||||
return NULL;
|
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 = %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->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());
|
//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){
|
void Faction::addUnit(Unit *unit){
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
bool isAlly(const Faction *faction);
|
bool isAlly(const Faction *faction);
|
||||||
|
|
||||||
//other
|
//other
|
||||||
Unit *findUnit(int id);
|
Unit *findUnit(int id) const;
|
||||||
void addUnit(Unit *unit);
|
void addUnit(Unit *unit);
|
||||||
void removeUnit(Unit *unit);
|
void removeUnit(Unit *unit);
|
||||||
void addStore(const UnitType *unitType);
|
void addStore(const UnitType *unitType);
|
||||||
|
|
|
@ -906,8 +906,7 @@ const Vec2i &PosCircularIterator::getPos(){
|
||||||
// class PosQuadIterator
|
// class PosQuadIterator
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
PosQuadIterator::PosQuadIterator(const Map *map, const Quad2i &quad, int step){
|
PosQuadIterator::PosQuadIterator(const Quad2i &quad, int step){
|
||||||
this->map= map;
|
|
||||||
this->quad= quad;
|
this->quad= quad;
|
||||||
this->boundingRect= quad.computeBoundingRect();
|
this->boundingRect= quad.computeBoundingRect();
|
||||||
this->step= step;
|
this->step= step;
|
||||||
|
|
|
@ -271,15 +271,14 @@ public:
|
||||||
// class PosQuadIterator
|
// class PosQuadIterator
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|
||||||
class PosQuadIterator{
|
class PosQuadIterator {
|
||||||
private:
|
private:
|
||||||
Quad2i quad;
|
Quad2i quad;
|
||||||
Rect2i boundingRect;
|
Rect2i boundingRect;
|
||||||
const Map *map;
|
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
int step;
|
int step;
|
||||||
public:
|
public:
|
||||||
PosQuadIterator(const Map *map, const Quad2i &quad, int step=1);
|
PosQuadIterator(const Quad2i &quad, int step=1);
|
||||||
bool next();
|
bool next();
|
||||||
void skipX();
|
void skipX();
|
||||||
const Vec2i &getPos();
|
const Vec2i &getPos();
|
||||||
|
|
|
@ -29,12 +29,15 @@ namespace Glest{ namespace Game{
|
||||||
// class PixmapInfo
|
// 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->leftDown= ld;
|
||||||
this->leftUp= lu;
|
this->leftUp= lu;
|
||||||
this->rightDown= rd;
|
this->rightDown= rd;
|
||||||
this->rightUp= ru;
|
this->rightUp= ru;
|
||||||
center= NULL;
|
center= NULL;
|
||||||
|
texture=NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceInfo::SurfaceInfo(const Pixmap2D *center) {
|
SurfaceInfo::SurfaceInfo(const Pixmap2D *center) {
|
||||||
|
@ -43,6 +46,7 @@ SurfaceInfo::SurfaceInfo(const Pixmap2D *center) {
|
||||||
this->rightDown= NULL;
|
this->rightDown= NULL;
|
||||||
this->rightUp= NULL;
|
this->rightUp= NULL;
|
||||||
this->center= center;
|
this->center= center;
|
||||||
|
texture=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SurfaceInfo::operator==(const SurfaceInfo &si) const {
|
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 i=0; i<map.getSurfaceW()-1; ++i){
|
||||||
for(int j=0; j<map.getSurfaceH()-1; ++j){
|
for(int j=0; j<map.getSurfaceH()-1; ++j){
|
||||||
Vec2f coord;
|
Vec2f coord;
|
||||||
const Texture2D *texture;
|
const Texture2D *texture=NULL;
|
||||||
SurfaceCell *sc00= map.getSurfaceCell(i, j);
|
SurfaceCell *sc00= map.getSurfaceCell(i, j);
|
||||||
SurfaceCell *sc10= map.getSurfaceCell(i+1, j);
|
SurfaceCell *sc10= map.getSurfaceCell(i+1, j);
|
||||||
SurfaceCell *sc01= map.getSurfaceCell(i, j+1);
|
SurfaceCell *sc01= map.getSurfaceCell(i, j+1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user