From 8271725320f669638587cfb9cec8433f9ac2cdc5 Mon Sep 17 00:00:00 2001 From: Japa Date: Mon, 24 Jun 2013 14:20:22 +0530 Subject: [PATCH] Some performance fixes and tweaks. Opaque blocks can now emit light. --- plugins/rendermax/renderer_light.cpp | 22 ++++++++++++++++------ plugins/rendermax/renderer_light.hpp | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index fcf4a3b0e..3b95be1e9 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -25,6 +25,7 @@ using namespace DFHack; using df::coord2d; const float levelDim=0.2f; +const float RootTwo = 1.4142135623730950488016887242097f; rect2d getMapViewport() { @@ -94,8 +95,9 @@ void plotLine(int x0, int y0, int x1, int y1,std::function=mapPort.first.x && ty>=mapPort.first.y && tx<=mapPort.second.x && ty<=mapPort.second.y) { size_t tile=getIndex(tx,ty); - float dsq=dx*dx+dy*dy; - float dt=sqrt(dsq); + int dsq=dx*dx+dy*dy; + float dt=1; + if(dsq == 1) + dt=1; + else if(dsq == 2) + dt = RootTwo; + else if(dsq == 0) + dt = 0; + else + dt=sqrt((float)dsq); lightCell& v=ocupancy[tile]; lightSource& ls=lights[tile]; bool wallhack=false; @@ -173,7 +183,7 @@ void lightingEngineViewscreen::doFovs() int surrounds = 0; lightCell curPower; - if(lightUpCell(curPower = power, 0, 0,i+0, j+0)) + lightUpCell(curPower = power, 0, 0,i+0, j+0); { surrounds += lightUpCell(curPower = power, 0, 1,i+0, j+1); surrounds += lightUpCell(curPower = power, 1, 1,i+1, j+1); @@ -517,7 +527,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() if(df::global::cursor->x>-30000) { lightSource cursor(lightCell(0.96f,0.84f,0.03f),11); - cursor.flicker=true; + 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 3744fd5bc..98ea502bd 100644 --- a/plugins/rendermax/renderer_light.hpp +++ b/plugins/rendermax/renderer_light.hpp @@ -127,4 +127,4 @@ private: int w,h; DFHack::rect2d mapPort; }; -#endif \ No newline at end of file +#endif