diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 962f49d28..9d064b959 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -30,6 +30,22 @@ using df::coord2d; const float levelDim=0.2f; const float RootTwo = 1.4142135623730950488016887242097f; +lightSource::lightSource(lightCell power,int radius):power(power),flicker(false) +{ + if(radius >= 0) + this->radius = radius; + else + { + float totalPower = power.r; + if(totalPower < power.g)totalPower = power.g; + if(totalPower < power.b)totalPower = power.b; + if(totalPower > 0 && levelDim > 0) + this->radius = (int)((log(levelDim/totalPower)/log(0.85f))) + 1; + else + this->radius = 0; + } +} + rect2d getMapViewport() { const int AREA_MAP_WIDTH = 23; @@ -99,6 +115,20 @@ void plotCircle(int xm, int ym, int r,std::function setPixel) if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */ } while (x < 0); } +void plotSquare(int xm, int ym, int r,std::function setPixel) +{ + for(int x = 0; x <= r; x++) + { + setPixel(xm+r, ym+x); /* I.1 Quadrant */ + setPixel(xm+x, ym+r); /* I.2 Quadrant */ + setPixel(xm+r, ym-x); /* II.1 Quadrant */ + setPixel(xm+x, ym-r); /* II.2 Quadrant */ + setPixel(xm-r, ym-x); /* III.1 Quadrant */ + setPixel(xm-x, ym-r); /* III.2 Quadrant */ + setPixel(xm-r, ym+x); /* IV.1 Quadrant */ + setPixel(xm-x, ym+r); /* IV.2 Quadrant */ + } +} void plotLine(int x0, int y0, int x1, int y1,std::function setPixel) { int dx = abs(x1-x0), sx = x0x>-30000) { - lightSource cursor(lightCell(0.96f,0.84f,0.03f),11); - cursor.flicker=false; + //lightSource cursor(lightCell(9.6f,8.4f,0.3f),-1); + //cursor.flicker=false; int wx=df::global::cursor->x-window_x+vp.first.x; int wy=df::global::cursor->y-window_y+vp.first.y; int tile=getIndex(wx,wy); diff --git a/plugins/rendermax/renderer_light.hpp b/plugins/rendermax/renderer_light.hpp index 285caa5a2..668a729a5 100644 --- a/plugins/rendermax/renderer_light.hpp +++ b/plugins/rendermax/renderer_light.hpp @@ -88,10 +88,7 @@ struct lightSource { } - lightSource(lightCell power,int radius):power(power),radius(radius),flicker(false) - { - - } + lightSource(lightCell power,int radius); float powerSquared()const { return power.r*power.r+power.g*power.g+power.b*power.b;