Changeset 672 for abuse/trunk/src/particle.cpp
 Timestamp:
 May 16, 2011, 2:37:35 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

abuse/trunk/src/particle.cpp
r665 r672 209 209 } 210 210 211 void scatter_line(int x1, int y1, int x2, int y2, int c, int s)211 void ScatterLine(vec2i p1, vec2i p2, int c, int s) 212 212 { 213 213 vec2i caa, cbb; 214 214 main_screen>GetClip(caa, cbb); 215 215 216 int t = abs( x2  x1 ) > abs( y2  y1 ) ? abs( x2  x1 ) + 1 : abs( y2  y1 ) + 1; 217 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2  x1 ) << 16 ) / t, dy = ( ( y2  y1 ) << 16 ) / t, x, y; 218 219 int xm = ( 1 << s ); 220 int ym = ( 1 << s ); 221 s = ( 15  s ); 216 int t = 1 + Max(abs(p2.x  p1.x), abs(p2.y  p1.y)); 217 int xo = p1.x << 16, 218 yo = p1.y << 16, 219 dx = ((p2.x  p1.x) << 16) / t, 220 dy = ((p2.y  p1.y) << 16) / t; 221 222 int xm = (1 << s); 223 int ym = (1 << s); 224 s = (15  s); 222 225 223 226 main_screen>Lock(); 224 while( t)225 { 226 x = ( xo >> 16 ) + ( jrand() >> s)  xm;227 y = ( yo >> 16 ) + ( jrand() >> s)  ym;228 if( !( x < caa.x  y < caa.y  x >= cbb.x  y >= cbb.y ))227 while(t) 228 { 229 int x = (xo >> 16) + (jrand() >> s)  xm; 230 int y = (yo >> 16) + (jrand() >> s)  ym; 231 if(!(x < caa.x  y < caa.y  x >= cbb.x  y >= cbb.y)) 229 232 { 230 *(main_screen>scan_line( y ) + x) = c;233 *(main_screen>scan_line(y) + x) = c; 231 234 } 232 235 xo += dx; … … 236 239 } 237 240 238 239 240 void ascatter_line(int x1, int y1, int x2, int y2, int c1, int c2, int s) 241 void AScatterLine(vec2i p1, vec2i p2, int c1, int c2, int s) 241 242 { 242 243 vec2i caa, cbb; 243 244 main_screen>GetClip(caa, cbb); 244 245 245 int t = abs( x2  x1 ) > abs( y2  y1 ) ? abs( x2  x1 ) + 1 : abs( y2  y1 ) + 1; 246 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2  x1 ) << 16 ) / t, dy = ( ( y2  y1 ) <<16 ) / t, x, y; 247 248 int xm = ( 1 << s ); 249 int ym = ( 1 << s ); 250 s = ( 15  s ); 246 int t = 1 + Max(abs(p2.x  p1.x), abs(p2.y  p1.y)); 247 int xo = p1.x << 16, 248 yo = p1.y << 16, 249 dx = ((p2.x  p1.x) << 16) / t, 250 dy = ((p2.y  p1.y) << 16) / t; 251 252 int xm = (1 << s); 253 int ym = (1 << s); 254 s = (15  s); 251 255 252 256 main_screen>Lock(); … … 255 259 uint8_t *addr; 256 260 257 while( t)258 { 259 x = ( xo >> 16 ) + ( jrand() >> s)  xm;260 y = ( yo >> 16 ) + ( jrand() >> s)  ym;261 while(t) 262 { 263 int x = (xo >> 16) + (jrand() >> s)  xm; 264 int y = (yo >> 16) + (jrand() >> s)  ym; 261 265 // FIXME: these clip values seemed wrong to me before the GetClip 262 266 // refactoring. 263 if( !( x <= caa.x  y <= caa.y  x >= cbb.x  1  y >= cbb.y  1))267 if(!(x <= caa.x  y <= caa.y  x >= cbb.x  1  y >= cbb.y  1)) 264 268 { 265 addr = main_screen>scan_line( y) + x;269 addr = main_screen>scan_line(y) + x; 266 270 *addr = c1; 267 271 *(addr + w) = c2;
Note: See TracChangeset
for help on using the changeset viewer.