Fixed non-circular light. Do not show hidden tiles.

develop
Warmist 2013-06-23 21:29:03 +03:00
parent f92e4c91b8
commit b3ba3b9107
2 changed files with 16 additions and 9 deletions

@ -108,6 +108,7 @@ bool lightingEngineViewscreen::lightUpCell(lightCell& power,int dx,int dy,int tx
{
size_t tile=getIndex(tx,ty);
float dsq=dx*dx+dy*dy;
float dt=sqrt(dsq);
lightCell& v=ocupancy[tile];
lightSource& ls=lights[tile];
bool wallhack=false;
@ -116,9 +117,9 @@ bool lightingEngineViewscreen::lightUpCell(lightCell& power,int dx,int dy,int tx
if (dsq>0 && !wallhack)
{
power.r=power.r*(pow(v.r,dsq));
power.g=power.g*(pow(v.g,dsq));
power.b=power.b*(pow(v.b,dsq));
power.r=power.r*(pow(v.r,dt));
power.g=power.g*(pow(v.g,dt));
power.b=power.b*(pow(v.b,dt));
}
if(ls.radius>0 && dsq>0)
{
@ -189,6 +190,7 @@ void lightingEngineViewscreen::updateWindow()
if(lightMap.size()!=myRenderer->lightGrid.size())
{
reinit();
myRenderer->invalidate();
return;
}
std::swap(lightMap,myRenderer->lightGrid);
@ -216,7 +218,9 @@ bool lightingEngineViewscreen::addLight(int tileId,const lightSource& light)
}
void lightingEngineViewscreen::doOcupancyAndLights()
{
lightSource sun(lightCell(1,1,1),15);
lightSource lava(lightCell(0.8f,0.2f,0.2f),5);
rect2d vp=getMapViewport();
int window_x=*df::global::window_x;
@ -306,15 +310,18 @@ void lightingEngineViewscreen::doOcupancyAndLights()
curCell=lightCell(0.85f,0.85f,0.85f);
df::tiletype* type = Maps::getTileType(x,y,window_z);
if(!type)
{
//unallocated, do sky
addLight(tile,sun);
continue;
}
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,*type);
df::tile_designation* d=Maps::getTileDesignation(x,y,window_z);
df::tile_designation* d2=Maps::getTileDesignation(x,y,window_z-1);
df::tile_occupancy* o=Maps::getTileOccupancy(x,y,window_z);
if(!o || !d )
continue;
if(shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::WALL || shape==df::tiletype_shape::TREE /*|| o->bits.building*/)
if(shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::WALL || shape==df::tiletype_shape::TREE || d->bits.hidden )
{
curCell=lightCell(0,0,0);
}
@ -366,12 +373,12 @@ void lightingEngineViewscreen::doOcupancyAndLights()
&& d2 && d2->bits.liquid_type && d2->bits.flow_size>0)
)
{
lightSource lava(lightCell(0.8f,0.2f,0.2f),5);
addLight(tile,lava);
}
if(d->bits.outside && d->bits.flow_size==0)
{
lightSource sun(lightCell(1,1,1),15);
addLight(tile,sun);
}

@ -59,7 +59,7 @@ public:
};
virtual void resize(int32_t w, int32_t h) {
renderer_wrap::resize(w,h);
reinitLightGrid(w,h);
reinitLightGrid();
}
};
class lightingEngine