MCPcopy Create free account
hub / github.com/DFHack/dfhack / doLight

Method doLight

plugins/rendermax/renderer_light.cpp:1366–1394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1364}
1365
1366void lightThread::doLight( int x,int y )
1367{
1368 using namespace std::placeholders;
1369 lightSource& csource=dispatch.lights[x*dispatch.getH()+y];
1370 int num_diffuse=dispatch.num_diffusion;
1371 if(csource.radius>0)
1372 {
1373 rgbf power=csource.power;
1374 int radius =csource.radius;
1375 if(csource.flicker)
1376 {
1377 float flicker=(rand()/(float)RAND_MAX)/2.0f+0.5f;
1378 radius*=flicker;
1379 power=power*flicker;
1380 }
1381 rgbf surrounds;
1382 lightUpCell( power, 0, 0,x, y); //light up the source itself
1383 for(int i=-1;i<2;i++)
1384 for(int j=-1;j<2;j++)
1385 if(i!=0||j!=0)
1386 surrounds += lightUpCell( power, i, j,x+i, y+j); //and this is wall hack (so that walls look nice)
1387 if(surrounds.dot(surrounds)>0.00001f) //if we needed to light up the suroundings, then raycast
1388 {
1389
1390 plotSquare(x,y,radius,
1391 std::bind(&lightThread::doRay,this,power,x,y,_1,_2,num_diffuse));
1392 }
1393 }
1394}
1395void lightThreadDispatch::signalDoneOcclusion()
1396{
1397 {

Callers

nothing calls this directly

Calls 3

plotSquareFunction · 0.85
dotMethod · 0.80
getHMethod · 0.45

Tested by

no test coverage detected