| 11 |
|
|
| 12 |
|
#include "ray.h" |
| 13 |
|
#include "view.h" |
| 14 |
+ |
#include "otypes.h" |
| 15 |
|
#include "source.h" |
| 16 |
|
|
| 17 |
|
|
| 70 |
|
|
| 71 |
|
static void |
| 72 |
|
clipregion( /* find intersection with boundary */ |
| 73 |
< |
register RREAL a[2], |
| 74 |
< |
register RREAL b[2], |
| 73 |
> |
RREAL a[2], |
| 74 |
> |
RREAL b[2], |
| 75 |
|
double cv, |
| 76 |
|
int crit, |
| 77 |
|
RREAL r[2] /* return value */ |
| 102 |
|
) |
| 103 |
|
{ |
| 104 |
|
RREAL *s, *p; |
| 105 |
< |
register int j, nvo; |
| 105 |
> |
int j, nvo; |
| 106 |
|
|
| 107 |
|
s = vl[nv-1]; |
| 108 |
|
nvo = 0; |
| 151 |
|
) |
| 152 |
|
{ |
| 153 |
|
double d2, w2, w2min, w2max; |
| 154 |
< |
register RREAL *p0, *p1, *p2; |
| 154 |
> |
RREAL *p0, *p1, *p2; |
| 155 |
|
int i, j; |
| 156 |
|
/* find minimum for all widths */ |
| 157 |
|
w2min = FHUGE; |
| 179 |
|
|
| 180 |
|
static void |
| 181 |
|
convex_center( /* compute center of convex polygon */ |
| 182 |
< |
register RREAL vl[][2], |
| 182 |
> |
RREAL vl[][2], |
| 183 |
|
int nv, |
| 184 |
|
RREAL cv[2] /* return value */ |
| 185 |
|
) |
| 186 |
|
{ |
| 187 |
< |
register int i; |
| 187 |
> |
int i; |
| 188 |
|
/* simple average (suboptimal) */ |
| 189 |
|
cv[0] = cv[1] = 0.; |
| 190 |
|
for (i = 0; i < nv; i++) { |
| 198 |
|
|
| 199 |
|
static double |
| 200 |
|
poly_area( /* compute area of polygon */ |
| 201 |
< |
register RREAL vl[][2], |
| 201 |
> |
RREAL vl[][2], |
| 202 |
|
int nv |
| 203 |
|
) |
| 204 |
|
{ |
| 205 |
|
double a; |
| 206 |
|
RREAL v0[2], v1[2]; |
| 207 |
< |
register int i; |
| 207 |
> |
int i; |
| 208 |
|
|
| 209 |
|
a = 0.; |
| 210 |
|
v0[0] = vl[1][0] - vl[0][0]; |
| 229 |
|
int nvo, nvt; |
| 230 |
|
RREAL vlt[MAXVERT][2]; |
| 231 |
|
double voa, vta; |
| 232 |
< |
register int i, j; |
| 232 |
> |
int i, j; |
| 233 |
|
/* start with original polygon */ |
| 234 |
|
for (i = nvo = nv; i--; ) { |
| 235 |
|
vlo[i][0] = vl[i][0]; vlo[i][1] = vl[i][1]; |
| 263 |
|
int nv |
| 264 |
|
) |
| 265 |
|
{ |
| 266 |
< |
register SPLIST *spn; |
| 267 |
< |
register int i; |
| 266 |
> |
SPLIST *spn; |
| 267 |
> |
int i; |
| 268 |
|
|
| 269 |
|
if (nv < 3) |
| 270 |
|
return; |
| 293 |
|
{0,1,3,7,6,4},{0,1,5,7,6,2}, |
| 294 |
|
{0,2,6,7,5,1},{0,4,6,7,3,1}, |
| 295 |
|
{0,2,3,7,5,4},{1,5,4,6,2,3}}; |
| 296 |
< |
register SRCREC *s = source + sn; |
| 296 |
> |
SRCREC *s = source + sn; |
| 297 |
|
FVECT ap, ip; |
| 298 |
|
RREAL pt[6][2]; |
| 299 |
|
int dir; |
| 300 |
< |
register int i, j; |
| 300 |
> |
int i, j; |
| 301 |
|
|
| 302 |
|
if (s->sflags & (SDISTANT|SFLAT)) { |
| 303 |
< |
if (s->sflags & SDISTANT && ourview.type == VT_PAR) |
| 304 |
< |
return(0); /* all or nothing case */ |
| 303 |
> |
if (s->sflags & SDISTANT) { |
| 304 |
> |
if (ourview.type == VT_PAR) |
| 305 |
> |
return(0); /* all or nothing case */ |
| 306 |
> |
if (s->srad >= 0.05) |
| 307 |
> |
return(0); /* should never be a problem */ |
| 308 |
> |
} |
| 309 |
|
if (s->sflags & SFLAT) { |
| 310 |
|
for (i = 0; i < 3; i++) |
| 311 |
|
ap[i] = s->sloc[i] - ourview.vp[i]; |
| 324 |
|
ap[i] += ourview.vp[i]; |
| 325 |
|
} |
| 326 |
|
} |
| 327 |
< |
viewloc(ip, &ourview, ap); /* find image point */ |
| 328 |
< |
if (ip[2] <= 0.) |
| 327 |
> |
/* find image point */ |
| 328 |
> |
if (viewloc(ip, &ourview, ap) <= 0) |
| 329 |
|
return(0); /* in front of view */ |
| 330 |
|
sp[j][0] = ip[0]; sp[j][1] = ip[1]; |
| 331 |
|
} |
| 348 |
|
if (cubeord[dir][j] & 4) ap[i] += s->ss[SW][i]; |
| 349 |
|
else ap[i] -= s->ss[SW][i]; |
| 350 |
|
} |
| 351 |
< |
viewloc(ip, &ourview, ap); /* find image point */ |
| 352 |
< |
if (ip[2] <= 0.) |
| 351 |
> |
/* find image point */ |
| 352 |
> |
if (viewloc(ip, &ourview, ap) <= 0) |
| 353 |
|
return(0); /* in front of view */ |
| 354 |
|
pt[j][0] = ip[0]; pt[j][1] = ip[1]; |
| 355 |
|
} |
| 358 |
|
|
| 359 |
|
|
| 360 |
|
/* initialize by finding sources smaller than rad */ |
| 361 |
< |
extern void |
| 361 |
> |
void |
| 362 |
|
init_drawsources( |
| 363 |
|
int rad /* source sample size */ |
| 364 |
|
) |
| 365 |
|
{ |
| 366 |
|
RREAL spoly[MAXVERT][2]; |
| 367 |
|
int nsv; |
| 368 |
< |
register SPLIST *sp; |
| 369 |
< |
register int i; |
| 368 |
> |
SPLIST *sp; |
| 369 |
> |
int i; |
| 370 |
|
/* free old source list if one */ |
| 371 |
|
for (sp = sphead; sp != NULL; sp = sphead) { |
| 372 |
|
sphead = sp->next; |
| 374 |
|
} |
| 375 |
|
/* loop through all sources */ |
| 376 |
|
for (i = nsources; i--; ) { |
| 377 |
+ |
/* skip illum's */ |
| 378 |
+ |
if (findmaterial(source[i].so)->otype == MAT_ILLUM) |
| 379 |
+ |
continue; |
| 380 |
|
/* compute image polygon for source */ |
| 381 |
|
if (!(nsv = sourcepoly(i, spoly))) |
| 382 |
|
continue; |
| 392 |
|
} |
| 393 |
|
} |
| 394 |
|
|
| 395 |
< |
extern void /* add sources smaller than rad to computed subimage */ |
| 395 |
> |
void /* add sources smaller than rad to computed subimage */ |
| 396 |
|
drawsources( |
| 397 |
|
COLOR *pic[], /* subimage pixel value array */ |
| 398 |
|
float *zbf[], /* subimage distance array (opt.) */ |
| 408 |
|
RREAL cxy[2]; |
| 409 |
|
double w; |
| 410 |
|
RAY sr; |
| 411 |
< |
register SPLIST *sp; |
| 412 |
< |
register int i; |
| 411 |
> |
SPLIST *sp; |
| 412 |
> |
int i; |
| 413 |
|
/* check each source in our list */ |
| 414 |
|
for (sp = sphead; sp != NULL; sp = sp->next) { |
| 415 |
|
/* clip source poly to subimage */ |
| 448 |
|
if (source[sp->sn].sflags & SSPOT && |
| 449 |
|
spotout(&sr, source[sp->sn].sl.s)) |
| 450 |
|
continue; /* outside spot */ |
| 451 |
< |
w = poly_area(ppoly, npv) * hres * vres; |
| 452 |
< |
if (w < .95) { /* subpixel source */ |
| 445 |
< |
rayorigin(&sr, NULL, SHADOW, 1.0); |
| 446 |
< |
sr.rsrc = sp->sn; |
| 447 |
< |
} else |
| 448 |
< |
rayorigin(&sr, NULL, PRIMARY, 1.0); |
| 451 |
> |
rayorigin(&sr, SHADOW, NULL, NULL); |
| 452 |
> |
sr.rsrc = sp->sn; |
| 453 |
|
rayvalue(&sr); /* compute value */ |
| 454 |
|
if (bright(sr.rcol) <= FTINY) |
| 455 |
|
continue; /* missed/blocked */ |
| 456 |
|
/* modify pixel */ |
| 457 |
+ |
w = poly_area(ppoly, npv) * hres * vres; |
| 458 |
|
if (zbf[y-y0] != NULL && |
| 459 |
< |
sr.rt < 0.99*zbf[y-y0][x-x0]) |
| 459 |
> |
sr.rt < 0.99*zbf[y-y0][x-x0]) { |
| 460 |
|
zbf[y-y0][x-x0] = sr.rt; |
| 461 |
< |
else if (!bigdiff(sr.rcol, pic[y-y0][x-x0], |
| 462 |
< |
0.01)) /* source sample */ |
| 463 |
< |
setcolor(pic[y-y0][x-x0], 0., 0., 0.); |
| 461 |
> |
} else if (!bigdiff(sr.rcol, pic[y-y0][x-x0], |
| 462 |
> |
0.01)) { /* source sample */ |
| 463 |
> |
scalecolor(pic[y-y0][x-x0], w); |
| 464 |
> |
continue; |
| 465 |
> |
} |
| 466 |
|
scalecolor(sr.rcol, w); |
| 467 |
|
scalecolor(pic[y-y0][x-x0], 1.-w); |
| 468 |
|
addcolor(pic[y-y0][x-x0], sr.rcol); |