9 |
|
|
10 |
|
#include "copyright.h" |
11 |
|
|
12 |
< |
#include "ray.h" |
12 |
> |
#include <string.h> |
13 |
|
|
14 |
+ |
#include "ray.h" |
15 |
|
#include "rpaint.h" |
15 |
– |
|
16 |
|
#include "random.h" |
17 |
|
|
18 |
|
#ifndef WFLUSH |
108 |
|
return(-1); |
109 |
|
} |
110 |
|
if (!direc || ourview.type == VT_PAR) { |
111 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
111 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
112 |
|
if (!localhit(&thisray, &thescene)) { |
113 |
|
error(COMMAND, "not a local object"); |
114 |
|
return(-1); |
122 |
|
VCOPY(vec, thisray.rdir); |
123 |
|
else |
124 |
|
VCOPY(vec, thisray.rop); |
125 |
< |
} else if (direc) |
126 |
< |
for (i = 0; i < 3; i++) |
127 |
< |
vec[i] -= ourview.vp[i]; |
125 |
> |
} else if (direc) { |
126 |
> |
for (i = 0; i < 3; i++) |
127 |
> |
vec[i] -= ourview.vp[i]; |
128 |
> |
if (normalize(vec) == 0.0) { |
129 |
> |
error(COMMAND, "point at view origin"); |
130 |
> |
return(-1); |
131 |
> |
} |
132 |
> |
} |
133 |
|
return(0); |
134 |
|
} |
135 |
|
|
170 |
|
h/hresolu, v/vresolu)) < -FTINY) { |
171 |
|
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
172 |
|
} else { |
173 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
174 |
< |
samplendx++; |
173 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
174 |
> |
samplendx = rand_samp ? random() : samplendx+1; |
175 |
|
rayvalue(&thisray); |
176 |
|
} |
177 |
|
|
376 |
|
if ((err = setview(vp)) != NULL) { |
377 |
|
sprintf(errmsg, "view not set - %s", err); |
378 |
|
error(COMMAND, errmsg); |
379 |
< |
} else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
380 |
< |
copystruct(&oldview, &ourview); |
381 |
< |
copystruct(&ourview, vp); |
379 |
> |
} else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
380 |
> |
oldview = ourview; |
381 |
> |
ourview = *vp; |
382 |
|
newimage(); |
383 |
|
} |
384 |
|
} |
391 |
|
{ |
392 |
|
double d; |
393 |
|
FVECT v1; |
394 |
< |
VIEW nv; |
394 |
> |
VIEW nv = ourview; |
395 |
|
register int i; |
396 |
|
|
392 |
– |
VCOPY(nv.vup, ourview.vup); |
393 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
397 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
398 |
|
if (elev != 0.0) { |
399 |
|
fcross(v1, ourview.vup, nv.vdir); |
400 |
|
normalize(v1); |
401 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
402 |
|
} |
403 |
< |
if ((nv.type = ourview.type) == VT_PAR) { |
404 |
< |
nv.horiz = ourview.horiz / mag; |
405 |
< |
nv.vert = ourview.vert / mag; |
403 |
> |
if (nv.type == VT_PAR) { |
404 |
> |
nv.horiz /= mag; |
405 |
> |
nv.vert /= mag; |
406 |
|
d = 0.0; /* don't move closer */ |
407 |
|
for (i = 0; i < 3; i++) |
408 |
|
d += (vc[i] - ourview.vp[i])*ourview.vdir[i]; |
406 |
– |
nv.vfore = ourview.vfore; |
407 |
– |
nv.vaft = ourview.vaft; |
409 |
|
} else { |
409 |
– |
nv.horiz = ourview.horiz; |
410 |
– |
nv.vert = ourview.vert; |
410 |
|
d = sqrt(dist2(ourview.vp, vc)) / mag; |
411 |
< |
if ((nv.vfore = ourview.vfore) > FTINY) { |
411 |
> |
if (nv.vfore > FTINY) { |
412 |
|
nv.vfore += d - d*mag; |
413 |
|
if (nv.vfore < 0.0) nv.vfore = 0.0; |
414 |
|
} |
415 |
< |
if ((nv.vaft = ourview.vaft) > FTINY) { |
415 |
> |
if (nv.vaft > FTINY) { |
416 |
|
nv.vaft += d - d*mag; |
417 |
|
if (nv.vaft <= nv.vfore) nv.vaft = 0.0; |
418 |
|
} |
419 |
+ |
nv.vdist /= mag; |
420 |
|
} |
421 |
|
for (i = 0; i < 3; i++) |
422 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |