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 |
|
|
377 |
|
sprintf(errmsg, "view not set - %s", err); |
378 |
|
error(COMMAND, errmsg); |
379 |
|
} else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
380 |
< |
copystruct(&oldview, &ourview); |
381 |
< |
copystruct(&ourview, vp); |
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 += d - d*mag; |
420 |
|
} |
421 |
|
for (i = 0; i < 3; i++) |
422 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |