Conflicts:
	plugins/rendermax/renderer_light.cpp
develop
Japa 2013-06-24 03:58:07 +05:30
commit a2cef2d86a
1 changed files with 43 additions and 39 deletions

@ -263,8 +263,8 @@ void lightingEngineViewscreen::doOcupancyAndLights()
int window_z=*df::global::window_z; int window_z=*df::global::window_z;
int vpW=vp.second.x-vp.first.x; int vpW=vp.second.x-vp.first.x;
int vpH=vp.second.y-vp.first.y; int vpH=vp.second.y-vp.first.y;
int endBlockx = (window_x+vpW); int endBlockx = (window_x+vpW)/16;
int endBlocky = (window_y+vpH); int endBlocky = (window_y+vpH)/16;
if(endBlockx >= df::global::world->map.x_count_block) endBlockx = df::global::world->map.x_count_block-1; if(endBlockx >= df::global::world->map.x_count_block) endBlockx = df::global::world->map.x_count_block-1;
if(endBlocky >= df::global::world->map.y_count_block) endBlocky = df::global::world->map.y_count_block-1; if(endBlocky >= df::global::world->map.y_count_block) endBlocky = df::global::world->map.y_count_block-1;
for(int blockx=window_x/16;blockx<=endBlockx;blockx++) for(int blockx=window_x/16;blockx<=endBlockx;blockx++)
@ -279,41 +279,39 @@ void lightingEngineViewscreen::doOcupancyAndLights()
} }
int totalBlank = 0; int totalBlank = 0;
int topLevel = df::global::world->map.z_count-1; int topLevel = df::global::world->map.z_count-1;
for(int ZZ = topLevel; (ZZ >= window_z) && totalBlank < 257; ZZ--) for(int ZZ = topLevel; (ZZ >= window_z) && totalBlank < 256; ZZ--)
{ {
df::map_block* block=Maps::getBlock(blockx,blocky,ZZ); df::map_block* block=Maps::getBlock(blockx,blocky,ZZ);
totalBlank = 0; totalBlank = 0;
if(block)
for(int block_x = 0; block_x < 16; block_x++) for(int block_x = 0; block_x < 16; block_x++)
for(int block_y = 0; block_y < 16; block_y++) for(int block_y = 0; block_y < 16; block_y++)
{ {
if(block) df::tiletype type = block->tiletype[block_x][block_y];
{ df::tile_designation d = block->designation[block_x][block_y];
df::tiletype type = block->tiletype[block_x][block_y]; df::tile_occupancy o = block->occupancy[block_x][block_y];
df::tile_designation d = block->designation[block_x][block_y]; df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,type);
df::tile_occupancy o = block->occupancy[block_x][block_y]; df::tiletype_shape_basic basic_shape = ENUM_ATTR(tiletype_shape, basic_shape, shape);
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,type);
df::tiletype_shape_basic basic_shape = ENUM_ATTR(tiletype_shape, basic_shape, shape);
if(basic_shape==df::tiletype_shape_basic::Wall) if(basic_shape==df::tiletype_shape_basic::Wall)
{ {
cellArray[block_x][block_y]=lightCell(0,0,0); cellArray[block_x][block_y]=lightCell(0,0,0);
} }
else if(basic_shape==df::tiletype_shape_basic::Floor || basic_shape==df::tiletype_shape_basic::Ramp || basic_shape==df::tiletype_shape_basic::Stair) else if(basic_shape==df::tiletype_shape_basic::Floor || basic_shape==df::tiletype_shape_basic::Ramp || basic_shape==df::tiletype_shape_basic::Stair)
{ {
if(ZZ!=window_z) if(ZZ!=window_z)
{
cellArray[block_x][block_y]=lightCell(0,0,0);
}
}
if(d.bits.liquid_type == df::enums::tile_liquid::Water && d.bits.flow_size)
{
cellArray[block_x][block_y] *= (lightCell(1,1,1) - (lightCell(1,1,1) - lightCell(0.63f,0.63f,0.75f))*(d.bits.flow_size/7));
}
else if(d.bits.liquid_type == df::enums::tile_liquid::Magma && d.bits.flow_size > 3)
{ {
cellArray[block_x][block_y]=lightCell(0,0,0); cellArray[block_x][block_y]=lightCell(0,0,0);
} }
} }
if(d.bits.liquid_type == df::enums::tile_liquid::Water && d.bits.flow_size)
{
cellArray[block_x][block_y] *= (lightCell(1,1,1) - (lightCell(1,1,1) - lightCell(0.63f,0.63f,0.75f))*(d.bits.flow_size/7));
}
else if(d.bits.liquid_type == df::enums::tile_liquid::Magma && d.bits.flow_size > 3)
{
cellArray[block_x][block_y]=lightCell(0,0,0);
}
if(cellArray[block_x][block_y].r < 0.003f && cellArray[block_x][block_y].g < 0.003f && cellArray[block_x][block_y].b < 0.003f) if(cellArray[block_x][block_y].r < 0.003f && cellArray[block_x][block_y].g < 0.003f && cellArray[block_x][block_y].b < 0.003f)
totalBlank++; totalBlank++;
} }
@ -329,9 +327,8 @@ void lightingEngineViewscreen::doOcupancyAndLights()
if(cellArray[block_x][block_y].r >= 0.003f && cellArray[block_x][block_y].g >= 0.003f && cellArray[block_x][block_y].b >= 0.003f) if(cellArray[block_x][block_y].r >= 0.003f && cellArray[block_x][block_y].g >= 0.003f && cellArray[block_x][block_y].b >= 0.003f)
{ {
int tile=getIndex(wx,wy); lightSource sun=lightSource(cellArray[block_x][block_y],15);
lightSource sun(cellArray[block_x][block_y],25); addLight(getIndex(wx,wy),sun);
addLight(tile,sun);
} }
} }
@ -345,21 +342,25 @@ void lightingEngineViewscreen::doOcupancyAndLights()
lightCell& curCell=ocupancy[tile]; lightCell& curCell=ocupancy[tile];
curCell=lightCell(0.85f,0.85f,0.85f); curCell=lightCell(0.85f,0.85f,0.85f);
df::tiletype* type = Maps::getTileType(x,y,window_z); df::tiletype* type = Maps::getTileType(x,y,window_z);
//if(!type) if(!type)
//{ {
// //unallocated, do sky //unallocated, do sky
// addLight(tile,sun); addLight(tile,sun);
// continue; continue;
//} }
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,*type); df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,*type);
df::tile_designation* d=Maps::getTileDesignation(x,y,window_z); df::tile_designation* d=Maps::getTileDesignation(x,y,window_z);
df::tile_designation* d2=Maps::getTileDesignation(x,y,window_z-1); df::tile_designation* d2=Maps::getTileDesignation(x,y,window_z-1);
df::tile_occupancy* o=Maps::getTileOccupancy(x,y,window_z); df::tile_occupancy* o=Maps::getTileOccupancy(x,y,window_z);
df::tiletype_material m=ENUM_ATTR(tiletype,material,*type);
if(!o || !d ) if(!o || !d )
continue; continue;
if(shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::WALL || shape==df::tiletype_shape::TREE || d->bits.hidden ) 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); if(shape==df::tiletype_shape::WALL && m==df::tiletype_material::FROZEN_LIQUID)
curCell*=lightCell(0.7,0.7,0.9);
else
curCell=lightCell(0,0,0);
} }
else if(o->bits.building) else if(o->bits.building)
{ {
@ -423,7 +424,6 @@ void lightingEngineViewscreen::doOcupancyAndLights()
{ {
curCell*=lightCell(0.7f,0.7f,0.8f); curCell*=lightCell(0.7f,0.7f,0.8f);
} }
//lights //lights
if((d->bits.liquid_type && d->bits.flow_size>0)|| if((d->bits.liquid_type && d->bits.flow_size>0)||
( (
@ -434,8 +434,12 @@ void lightingEngineViewscreen::doOcupancyAndLights()
addLight(tile,lava); addLight(tile,lava);
} }
} if(d->bits.outside && d->bits.flow_size==0)
{
addLight(tile,sun);
}
}
for(int blockx=window_x/16;blockx<=endBlockx;blockx++) for(int blockx=window_x/16;blockx<=endBlockx;blockx++)
for(int blocky=window_y/16;blocky<=endBlocky;blocky++) for(int blocky=window_y/16;blocky<=endBlocky;blocky++)
{ {