| 22 |
|
|
| 23 |
|
long nrays = 0L; /* number of rays traced */ |
| 24 |
|
|
| 25 |
< |
#define MAXLOOP 32 /* modifier loop detection */ |
| 25 |
> |
#define MAXLOOP 128 /* modifier loop detection */ |
| 26 |
|
|
| 27 |
|
#define RAYHIT (-1) /* return value for intercepted ray */ |
| 28 |
|
|
| 56 |
|
r->newcset = r->clipset; |
| 57 |
|
r->ro = NULL; |
| 58 |
|
r->rot = FHUGE; |
| 59 |
– |
r->rofs = 1.0; setident4(r->rofx); |
| 60 |
– |
r->robs = 1.0; setident4(r->robx); |
| 59 |
|
r->pert[0] = r->pert[1] = r->pert[2] = 0.0; |
| 60 |
|
setcolor(r->pcol, 1.0, 1.0, 1.0); |
| 61 |
|
setcolor(r->rcol, 0.0, 0.0, 0.0); |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
rayvalue(r) /* compute a ray's value */ |
| 67 |
< |
register RAY *r; |
| 67 |
> |
RAY *r; |
| 68 |
|
{ |
| 69 |
|
extern int (*trace)(); |
| 70 |
|
|
| 71 |
< |
if (localhit(r, &thescene)) |
| 72 |
< |
if (r->clipset != NULL && inset(r->clipset, r->ro->omod)) |
| 75 |
< |
raytrans(r); /* object is clipped */ |
| 76 |
< |
else |
| 77 |
< |
rayshade(r, r->ro->omod); |
| 78 |
< |
else if (sourcehit(r)) |
| 79 |
< |
rayshade(r, r->ro->omod); |
| 71 |
> |
if (localhit(r, &thescene) || sourcehit(r)) |
| 72 |
> |
raycont(r); |
| 73 |
|
|
| 74 |
|
if (trace != NULL) |
| 75 |
|
(*trace)(r); /* trace execution */ |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
|
| 79 |
+ |
raycont(r) /* check for clipped object and continue */ |
| 80 |
+ |
register RAY *r; |
| 81 |
+ |
{ |
| 82 |
+ |
if (r->clipset != NULL && inset(r->clipset, r->ro->omod)) |
| 83 |
+ |
raytrans(r); |
| 84 |
+ |
else |
| 85 |
+ |
rayshade(r, r->ro->omod); |
| 86 |
+ |
} |
| 87 |
+ |
|
| 88 |
+ |
|
| 89 |
|
raytrans(r) /* transmit ray as is */ |
| 90 |
< |
RAY *r; |
| 90 |
> |
register RAY *r; |
| 91 |
|
{ |
| 92 |
|
RAY tr; |
| 93 |
|
|
| 107 |
|
register OBJREC *m; |
| 108 |
|
/* check for infinite loop */ |
| 109 |
|
if (depth++ >= MAXLOOP) |
| 110 |
< |
objerror(r->ro, USER, "material loop"); |
| 110 |
> |
objerror(r->ro, USER, "possible modifier loop"); |
| 111 |
|
for ( ; mod != OVOID; mod = m->omod) { |
| 112 |
|
m = objptr(mod); |
| 113 |
+ |
/****** unnecessary test since modifier() is always called |
| 114 |
|
if (!ismodifier(m->otype)) { |
| 115 |
|
sprintf(errmsg, "illegal modifier \"%s\"", m->oname); |
| 116 |
|
error(USER, errmsg); |
| 117 |
|
} |
| 118 |
+ |
******/ |
| 119 |
|
(*ofun[m->otype].funp)(m, r); /* execute function */ |
| 120 |
|
m->lastrno = r->rno; |
| 121 |
|
if (ismaterial(m->otype)) { /* materials call raytexture */ |
| 210 |
|
* still fraught with problems since reflected rays and similar |
| 211 |
|
* directions calculated from the surface normal may spawn rays behind |
| 212 |
|
* the surface. The only solution is to curb textures at high |
| 213 |
< |
* incidence (Rdot << 1). |
| 213 |
> |
* incidence (namely, keep DOT(rdir,pert) < Rdot). |
| 214 |
|
*/ |
| 215 |
|
|
| 216 |
|
for (i = 0; i < 3; i++) |