| 150 | } |
| 151 | } |
| 152 | void 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 | } |
| 174 | void 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 | |