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

Function plotLine

plugins/rendermax/renderer_light.cpp:152–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150 }
151}
152void plotLine(int x0, int y0, int x1, int y1,rgbf power,const std::function<rgbf(rgbf,int,int,int,int)>& setPixel)
153{
154 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
155 int dy = -abs(y1-y0), sy = y0<y1 ? 1 : -1;
156 int err = dx+dy, e2; /* error value e_xy */
157 int rdx=0;
158 int rdy=0;
159 for(;;){ /* loop */
160 if(rdx!=0 || rdy!=0) //dirty hack to skip occlusion on the first tile.
161 {
162 power=setPixel(power,rdx,rdy,x0,y0);
163 if(power.dot(power)<0.00001f)
164 return ;
165 }
166 if (x0==x1 && y0==y1) break;
167 e2 = 2*err;
168 rdx=rdy=0;
169 if (e2 >= dy) { err += dy; x0 += sx; rdx=sx;} /* e_xy+e_x > 0 */
170 if (e2 <= dx) { err += dx; y0 += sy; rdy=sy;} /* e_xy+e_y < 0 */
171 }
172 return ;
173}
174void plotLineDiffuse(int x0, int y0, int x1, int y1,rgbf power,int num_diffuse,const std::function<rgbf(rgbf,int,int,int,int)>& setPixel,bool skip_hack=false)
175{
176

Callers

nothing calls this directly

Calls 1

dotMethod · 0.80

Tested by

no test coverage detected