19 |
|
|
20 |
|
#include "face.h" |
21 |
|
|
22 |
< |
#define SRCINC 4 /* realloc increment for array */ |
22 |
> |
#define SRCINC 8 /* realloc increment for array */ |
23 |
|
|
24 |
|
SRCREC *source = NULL; /* our list of sources */ |
25 |
|
int nsources = 0; /* the number of sources */ |
60 |
|
return(-1); |
61 |
|
source[nsources].sflags = 0; |
62 |
|
source[nsources].nhits = 1; |
63 |
< |
source[nsources].ntests = 2; /* initial hit probability = 1/2 */ |
63 |
> |
source[nsources].ntests = 2; /* initial hit probability = 50% */ |
64 |
> |
#if SHADCACHE |
65 |
> |
source[nsources].obscache = NULL; |
66 |
> |
#endif |
67 |
|
return(nsources++); |
68 |
|
} |
69 |
|
|
101 |
|
src->so = so; |
102 |
|
/* get the face */ |
103 |
|
f = getface(so); |
104 |
+ |
if (f->area == 0.0) |
105 |
+ |
objerror(so, USER, "zero source area"); |
106 |
|
/* find the center */ |
107 |
|
for (j = 0; j < 3; j++) { |
108 |
|
src->sloc[j] = 0.0; |
111 |
|
src->sloc[j] /= (double)f->nv; |
112 |
|
} |
113 |
|
if (!inface(src->sloc, f)) |
114 |
< |
objerror(so, USER, "cannot hit center"); |
114 |
> |
objerror(so, USER, "cannot hit source center"); |
115 |
|
src->sflags |= SFLAT; |
116 |
|
VCOPY(src->snorm, f->norm); |
117 |
|
src->ss2 = f->area; |
173 |
|
if (so->oargs.nfargs != 4) |
174 |
|
objerror(so, USER, "bad # arguments"); |
175 |
|
if (so->oargs.farg[3] <= FTINY) |
176 |
< |
objerror(so, USER, "illegal radius"); |
176 |
> |
objerror(so, USER, "illegal source radius"); |
177 |
|
VCOPY(src->sloc, so->oargs.farg); |
178 |
|
src->srad = so->oargs.farg[3]; |
179 |
|
src->ss2 = PI * src->srad * src->srad; |
195 |
|
src->so = so; |
196 |
|
/* get the ring */ |
197 |
|
co = getcone(so, 0); |
198 |
+ |
if (CO_R1(co) <= FTINY) |
199 |
+ |
objerror(so, USER, "illegal source radius"); |
200 |
|
VCOPY(src->sloc, CO_P0(co)); |
201 |
|
if (CO_R0(co) > 0.0) |
202 |
< |
objerror(so, USER, "cannot hit center"); |
202 |
> |
objerror(so, USER, "cannot hit source center"); |
203 |
|
src->sflags |= SFLAT; |
204 |
|
VCOPY(src->snorm, co->ad); |
205 |
|
src->srad = CO_R1(co); |
220 |
|
src->so = so; |
221 |
|
/* get the cylinder */ |
222 |
|
co = getcone(so, 0); |
223 |
+ |
if (CO_R0(co) <= FTINY) |
224 |
+ |
objerror(so, USER, "illegal source radius"); |
225 |
|
if (CO_R0(co) > .2*co->al) /* heuristic constraint */ |
226 |
|
objerror(so, WARNING, "source aspect too small"); |
227 |
|
src->sflags |= SCYL; |
255 |
|
return(ns); |
256 |
|
if ((ns = (SPOT *)malloc(sizeof(SPOT))) == NULL) |
257 |
|
return(NULL); |
258 |
+ |
if (m->oargs.farg[3] <= FTINY) |
259 |
+ |
objerror(m, USER, "zero angle"); |
260 |
|
ns->siz = 2.0*PI * (1.0 - cos(PI/180.0/2.0 * m->oargs.farg[3])); |
261 |
|
VCOPY(ns->aim, m->oargs.farg+4); |
262 |
|
if ((ns->flen = normalize(ns->aim)) == 0.0) |