ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rv3.c
(Generate patch)

Comparing ray/src/rt/rv3.c (file contents):
Revision 1.13 by greg, Thu Feb 22 11:46:15 1990 UTC vs.
Revision 2.42 by greg, Thu Nov 8 00:54:07 2018 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1987 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  rv3.c - miscellaneous routines for rview.
6   *
7 < *     5/11/87
7 > *  External symbols declared in rpaint.h
8   */
9  
10 < #include  "ray.h"
10 > #include "copyright.h"
11  
12 < #include  "octree.h"
12 > #include <string.h>
13  
14 + #include  "ray.h"
15   #include  "rpaint.h"
16 <
16 > #include  "otypes.h"
17 > #include  "otspecial.h"
18   #include  "random.h"
19  
20   #ifndef WFLUSH
21 < #define WFLUSH          30              /* flush after this many rays */
21 > #define WFLUSH          64              /* flush after this many primary rays */
22   #endif
23 + #ifndef WFLUSH1
24 + #define WFLUSH1         512             /* or this many total rays */
25 + #endif
26  
27  
28 < getrect(s, r)                           /* get a box */
29 < char  *s;
30 < register RECT  *r;
28 > #ifdef  SMLFLT
29 > #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
30 > #else
31 > #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
32 > #endif
33 >
34 > extern int      ray_pnprocs;
35 >
36 > static RNUMBER  niflush;                /* flushes since newimage() */
37 >
38 > int
39 > getrect(                                /* get a box */
40 >        char  *s,
41 >        RECT  *r
42 > )
43   {
44          int  x0, y0, x1, y1;
45  
# Line 69 | Line 83 | register RECT  *r;
83   }
84  
85  
86 < getinterest(s, direc, vec, mp)          /* get area of interest */
87 < char  *s;
88 < int  direc;
89 < FVECT  vec;
90 < double  *mp;
86 > int
87 > getinterest(            /* get area of interest */
88 >        char  *s,
89 >        int  direc,
90 >        FVECT  vec,
91 >        double  *mp
92 > )
93   {
94          int  x, y;
95          RAY  thisray;
96 <        register int  i;
96 >        int  i;
97  
98          if (sscanf(s, "%lf", mp) != 1)
99                  *mp = 1.0;
# Line 87 | Line 103 | double  *mp;
103                  error(COMMAND, "illegal magnification");
104                  return(-1);
105          }
106 <        if (sscanf(s, "%*lf %lf %lf %lf", &vec[0], &vec[1], &vec[2]) != 3) {
106 >        if (!sscanvec(sskip(s), vec)) {
107                  if (dev->getcur == NULL)
108                          return(-1);
109                  (*dev->comout)("Pick view center\n");
110                  if ((*dev->getcur)(&x, &y) == ABORT)
111                          return(-1);
112 <                viewray(thisray.rorg, thisray.rdir, &ourview,
113 <                                (x+.5)/hresolu, (y+.5)/vresolu);
112 >                if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
113 >                        &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
114 >                        error(COMMAND, "not on image");
115 >                        return(-1);
116 >                }
117                  if (!direc || ourview.type == VT_PAR) {
118 <                        rayorigin(&thisray, NULL, PRIMARY, 1.0);
119 <                        if (!localhit(&thisray, &thescene)) {
118 >                        rayorigin(&thisray, PRIMARY, NULL, NULL);
119 >                        while (localhit(&thisray, &thescene)) {
120 >                                OBJREC  *m = findmaterial(thisray.ro);
121 >                                if (m != NULL && !istransp(m->otype) &&
122 >                                                !isBSDFproxy(m) &&
123 >                                                (thisray.clipset == NULL ||
124 >                                                        !inset(thisray.clipset,
125 >                                                            thisray.ro->omod)))
126 >                                        break;          /* found something */
127 >                                VCOPY(thisray.rorg, thisray.rop);
128 >                                rayclear(&thisray);     /* skip invisible */
129 >                        }
130 >                        if ((thisray.ro == NULL) | (thisray.ro == &Aftplane)) {
131                                  error(COMMAND, "not a local object");
132                                  return(-1);
133                          }
# Line 110 | Line 140 | double  *mp;
140                                  VCOPY(vec, thisray.rdir);
141                  else
142                          VCOPY(vec, thisray.rop);
143 <        } else if (direc)
144 <                        for (i = 0; i < 3; i++)
145 <                                vec[i] -= ourview.vp[i];
143 >        } else if (direc) {
144 >                for (i = 0; i < 3; i++)
145 >                        vec[i] -= ourview.vp[i];
146 >                if (normalize(vec) == 0.0) {
147 >                        error(COMMAND, "point at view origin");
148 >                        return(-1);
149 >                }
150 >        }
151          return(0);
152   }
153  
154  
155 < float *         /* keep consistent with COLOR typedef */
156 < greyof(col)                             /* convert color to greyscale */
157 < register COLOR  col;
155 > COLORV *
156 > greyof(                         /* convert color to greyscale */
157 >        COLOR  col
158 > )
159   {
160          static COLOR  gcol;
161          double  b;
# Line 129 | Line 165 | register COLOR  col;
165          return(gcol);
166   }
167  
168 + static void
169 + recolor(                                        /* recolor the given node */
170 +        PNODE *p
171 + )
172 + {
173 +        while (p->kid != NULL) {                /* need to propogate down */
174 +                int  mx = (p->xmin + p->xmax) >> 1;
175 +                int  my = (p->ymin + p->ymax) >> 1;
176 +                int  ki;
177 +                if (p->x >= mx)
178 +                        ki = (p->y >= my) ? UR : DR;
179 +                else
180 +                        ki = (p->y >= my) ? UL : DL;
181 +                pcopy(p, p->kid+ki);
182 +                p = p->kid + ki;
183 +        }
184  
185 < paint(p, xmin, ymin, xmax, ymax)        /* compute and paint a rectangle */
186 < register PNODE  *p;
187 < int  xmin, ymin, xmax, ymax;
185 >        (*dev->paintr)(greyscale?greyof(p->v):p->v,
186 >                        p->xmin, p->ymin, p->xmax, p->ymax);
187 > }
188 >
189 > int
190 > paint(                  /* compute and paint a rectangle */
191 >        PNODE  *p
192 > )
193   {
137        extern long  nrays;
138        static long  lastflush = 0;
194          static RAY  thisray;
195          double  h, v;
141        register int  i;
196  
197 <        if (xmax - xmin <= 0 || ymax - ymin <= 0) {     /* empty */
198 <                p->x = xmin;
199 <                p->y = ymin;
197 >        if ((p->xmax <= p->xmin) | (p->ymax <= p->ymin)) {      /* empty */
198 >                p->x = p->xmin;
199 >                p->y = p->ymin;
200                  setcolor(p->v, 0.0, 0.0, 0.0);
201 <                return;
201 >                return(0);
202          }
203                                                  /* jitter ray direction */
204 <        p->x = h = xmin + (xmax-xmin)*frandom();
205 <        h /= hresolu;
152 <        p->y = v = ymin + (ymax-ymin)*frandom();
153 <        v /= vresolu;
204 >        p->x = h = p->xmin + (p->xmax-p->xmin)*frandom();
205 >        p->y = v = p->ymin + (p->ymax-p->ymin)*frandom();
206          
207 <        viewray(thisray.rorg, thisray.rdir, &ourview, h, v);
207 >        if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
208 >                        h/hresolu, v/vresolu)) < -FTINY) {
209 >                setcolor(thisray.rcol, 0.0, 0.0, 0.0);
210 >        } else if (!ray_pnprocs) {              /* immediate mode */
211 >                ray_trace(&thisray);
212 >        } else {                                /* queuing mode */
213 >                int     rval;
214 >                rayorigin(&thisray, PRIMARY, NULL, NULL);
215 >                thisray.rno = (RNUMBER)p;
216 >                rval = ray_pqueue(&thisray);
217 >                if (!rval)
218 >                        return(0);
219 >                if (rval < 0)
220 >                        return(-1);
221 >                                                /* get node for returned ray */
222 >                p = (PNODE *)thisray.rno;
223 >        }
224  
157        rayorigin(&thisray, NULL, PRIMARY, 1.0);
158        
159        rayvalue(&thisray);
160
225          copycolor(p->v, thisray.rcol);
162
226          scalecolor(p->v, exposure);
227  
228 <        (*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax);
228 >        recolor(p);                             /* paint it */
229  
230 <        if (dev->flush != NULL && nrays - lastflush >= WFLUSH) {
231 <                lastflush = nrays;
232 <                (*dev->flush)();
230 >        if (dev->flush != NULL) {               /* shall we check for input? */
231 >                static RNUMBER  lastflush = 0;
232 >                RNUMBER         counter = raynum;
233 >                int             flushintvl;
234 >                if (!ray_pnprocs) {
235 >                        counter = nrays;
236 >                        flushintvl = WFLUSH1;
237 >                } else if (ambounce == 0)
238 >                        flushintvl = ray_pnprocs*WFLUSH;
239 >                else if (niflush < WFLUSH)
240 >                        flushintvl = ray_pnprocs*niflush/(ambounce*(ambounce>0)+1);
241 >                else
242 >                        flushintvl = ray_pnprocs*WFLUSH/(ambounce*(ambounce>0)+1);
243 >                if (lastflush > counter)
244 >                        lastflush = 0;          /* counter wrapped */
245 >
246 >                if (counter - lastflush >= flushintvl) {
247 >                        lastflush = counter;
248 >                        (*dev->flush)();
249 >                        niflush++;
250 >                }
251          }
252 +        return(1);
253   }
254  
255  
256 < newimage()                              /* start a new image */
256 > int
257 > waitrays(void)                                  /* finish up pending rays */
258   {
259 +        int     nwaited = 0;
260 +        int     rval;
261 +        RAY     raydone;
262 +
263 +        if (!ray_pnprocs)                       /* immediate mode? */
264 +                return(0);
265 +        while ((rval = ray_presult(&raydone, 0)) > 0) {
266 +                PNODE  *p = (PNODE *)raydone.rno;
267 +                copycolor(p->v, raydone.rcol);
268 +                scalecolor(p->v, exposure);
269 +                recolor(p);
270 +                nwaited++;
271 +        }
272 +        if (rval < 0)
273 +                return(-1);
274 +        return(nwaited);
275 + }
276 +
277 +
278 + void
279 + newimage(                                       /* start a new image */
280 +        char *s
281 + )
282 + {
283 +        int             newnp = 0;
284 +                                                /* # rendering procs arg? */
285 +        if (s != NULL)
286 +                sscanf(s, "%d", &newnp);
287                                                  /* free old image */
288          freepkids(&ptrunk);
289                                                  /* compute resolution */
290          hresolu = dev->xsiz;
291          vresolu = dev->ysiz;
292          normaspect(viewaspect(&ourview), &dev->pixaspect, &hresolu, &vresolu);
293 <        pframe.l = pframe.d = 0;
294 <        pframe.r = hresolu; pframe.u = vresolu;
293 >        ptrunk.xmin = ptrunk.ymin = pframe.l = pframe.d = 0;
294 >        ptrunk.xmax = pframe.r = hresolu;
295 >        ptrunk.ymax = pframe.u = vresolu;
296          pdepth = 0;
297                                                  /* clear device */
298          (*dev->clear)(hresolu, vresolu);
299 <                                                /* get first value */
300 <        paint(&ptrunk, 0, 0, hresolu, vresolu);
299 >
300 >        if (newparam) {                         /* (re)start rendering procs */
301 >                if (ray_pnprocs)
302 >                        ray_pclose(0);          /* should already be closed */
303 >                if (newnp > 0)
304 >                        nproc = newnp;
305 >                if (nproc > 1)
306 >                        ray_popen(nproc);
307 >                newparam = 0;
308 >        } else if ((newnp > 0) & (newnp != nproc)) {
309 >                if (newnp == 1)                 /* change # rendering procs */
310 >                        ray_pclose(0);
311 >                else if (newnp < ray_pnprocs)
312 >                        ray_pclose(ray_pnprocs - newnp);
313 >                else
314 >                        ray_popen(newnp - ray_pnprocs);
315 >                nproc = newnp;
316 >        }
317 >        niflush = 0;                            /* get first value */
318 >        paint(&ptrunk);
319   }
320  
321  
322 < redraw()                                /* redraw the image */
322 > void
323 > redraw(void)                            /* redraw the image */
324   {
325          (*dev->clear)(hresolu, vresolu);
326          (*dev->comout)("redrawing...\n");
# Line 198 | Line 329 | redraw()                               /* redraw the image */
329   }
330  
331  
332 < repaint(xmin, ymin, xmax, ymax)                 /* repaint a region */
333 < int  xmin, ymin, xmax, ymax;
332 > void
333 > repaint(                                /* repaint a region */
334 >        int  xmin,
335 >        int  ymin,
336 >        int  xmax,
337 >        int  ymax
338 > )
339   {
340          RECT  reg;
341  
342          reg.l = xmin; reg.r = xmax;
343          reg.d = ymin; reg.u = ymax;
344  
345 <        paintrect(&ptrunk, 0, 0, hresolu, vresolu, &reg);
345 >        paintrect(&ptrunk, &reg);
346   }
347  
348  
349 < paintrect(p, xmin, ymin, xmax, ymax, r)         /* paint picture rectangle */
350 < register PNODE  *p;
351 < int  xmin, ymin, xmax, ymax;
352 < register RECT  *r;
349 > void
350 > paintrect(                              /* paint picture rectangle */
351 >        PNODE  *p,
352 >        RECT  *r
353 > )
354   {
355          int  mx, my;
356  
357 <        if (xmax - xmin <= 0 || ymax - ymin <= 0)
357 >        if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0)
358                  return;
359  
360          if (p->kid == NULL) {
361                  (*dev->paintr)(greyscale?greyof(p->v):p->v,
362 <                                xmin, ymin, xmax, ymax);        /* do this */
362 >                        p->xmin, p->ymin, p->xmax, p->ymax);    /* do this */
363                  return;
364          }
365 <        mx = (xmin + xmax) >> 1;                                /* do kids */
366 <        my = (ymin + ymax) >> 1;
365 >        mx = (p->xmin + p->xmax) >> 1;                          /* do kids */
366 >        my = (p->ymin + p->ymax) >> 1;
367          if (mx > r->l) {
368                  if (my > r->d)
369 <                        paintrect(p->kid+DL, xmin, ymin, mx, my, r);
369 >                        paintrect(p->kid+DL, r);
370                  if (my < r->u)
371 <                        paintrect(p->kid+UL, xmin, my, mx, ymax, r);
371 >                        paintrect(p->kid+UL, r);
372          }
373          if (mx < r->r) {
374                  if (my > r->d)
375 <                        paintrect(p->kid+DR, mx, ymin, xmax, my, r);
375 >                        paintrect(p->kid+DR, r);
376                  if (my < r->u)
377 <                        paintrect(p->kid+UR, mx, my, xmax, ymax, r);
377 >                        paintrect(p->kid+UR, r);
378          }
379   }
380  
381  
382   PNODE *
383 < findrect(x, y, p, r, pd)                /* find a rectangle */
384 < int  x, y;
385 < register PNODE  *p;
386 < register RECT  *r;
387 < int  pd;
383 > findrect(                               /* find a rectangle */
384 >        int  x,
385 >        int  y,
386 >        PNODE  *p,
387 >        int  pd
388 > )
389   {
390          int  mx, my;
391  
392          while (p->kid != NULL && pd--) {
393  
394 <                mx = (r->l + r->r) >> 1;
395 <                my = (r->d + r->u) >> 1;
394 >                mx = (p->xmin + p->xmax) >> 1;
395 >                my = (p->ymin + p->ymax) >> 1;
396  
397                  if (x < mx) {
260                        r->r = mx;
398                          if (y < my) {
262                                r->u = my;
399                                  p = p->kid+DL;
400                          } else {
265                                r->d = my;
401                                  p = p->kid+UL;
402                          }
403                  } else {
269                        r->l = mx;
404                          if (y < my) {
271                                r->u = my;
405                                  p = p->kid+DR;
406                          } else {
274                                r->d = my;
407                                  p = p->kid+UR;
408                          }
409                  }
# Line 280 | Line 412 | int  pd;
412   }
413  
414  
415 < scalepict(p, sf)                        /* scale picture values */
416 < register PNODE  *p;
417 < double  sf;
415 > void
416 > compavg(                                /* recompute averages */
417 >        PNODE   *p
418 > )
419   {
420 +        int     i, navg;
421 +        
422 +        if (p->kid == NULL)
423 +                return;
424 +
425 +        setcolor(p->v, .0, .0, .0);
426 +        navg = 0;
427 +        for (i = 0; i < 4; i++) {
428 +                if (p->kid[i].xmin >= p->kid[i].xmax) continue;
429 +                if (p->kid[i].ymin >= p->kid[i].ymax) continue;
430 +                compavg(p->kid+i);
431 +                addcolor(p->v, p->kid[i].v);
432 +                navg++;
433 +        }
434 +        if (navg > 1)
435 +                scalecolor(p->v, 1./navg);
436 + }
437 +
438 +
439 + void
440 + scalepict(                              /* scale picture values */
441 +        PNODE  *p,
442 +        double  sf
443 + )
444 + {
445          scalecolor(p->v, sf);           /* do this node */
446  
447          if (p->kid == NULL)
# Line 296 | Line 454 | double  sf;
454   }
455  
456  
457 < getpictcolrs(yoff, scan, p, xsiz, ysiz) /* get scanline from picture */
458 < int  yoff;
459 < register COLR  *scan;
460 < register PNODE  *p;
461 < int  xsiz, ysiz;
457 > void
458 > getpictcolrs(                           /* get scanline from picture */
459 >        int  yoff,
460 >        COLR  *scan,
461 >        PNODE  *p,
462 >        int  xsiz,
463 >        int  ysiz
464 > )
465   {
466 <        register int  mx;
466 >        int  mx;
467          int  my;
468  
469          if (p->kid == NULL) {                   /* do this node */
# Line 326 | Line 487 | int  xsiz, ysiz;
487   }
488  
489  
490 < pcopy(p1, p2)                           /* copy paint node p1 into p2 */
491 < register PNODE  *p1, *p2;
490 > void
491 > freepkids(                              /* free pnode's children */
492 >        PNODE  *p
493 > )
494   {
332        copycolor(p2->v, p1->v);
333        p2->x = p1->x;
334        p2->y = p1->y;
335 }
336
337
338 freepkids(p)                            /* free pnode's children */
339 register PNODE  *p;
340 {
495          if (p->kid == NULL)
496                  return;
497          freepkids(p->kid+DL);
498          freepkids(p->kid+DR);
499          freepkids(p->kid+UL);
500          freepkids(p->kid+UR);
501 <        free((char *)p->kid);
501 >        free((void *)p->kid);
502          p->kid = NULL;
503   }
504  
505  
506 < newview(vp)                             /* change viewing parameters */
507 < register VIEW  *vp;
506 > void
507 > newview(                                        /* change viewing parameters */
508 >        VIEW  *vp
509 > )
510   {
511          char  *err;
512  
513          if ((err = setview(vp)) != NULL) {
514                  sprintf(errmsg, "view not set - %s", err);
515                  error(COMMAND, errmsg);
516 <        } else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) {
517 <                copystruct(&oldview, &ourview);
518 <                copystruct(&ourview, vp);
519 <                newimage();             /* newimage() calls with vp=&ourview! */
516 >        } else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) {
517 >                oldview = ourview;
518 >                ourview = *vp;
519 >                newimage(NULL);
520          }
521   }
522  
523  
524 < moveview(angle, elev, mag, vc)                  /* move viewpoint */
525 < double  angle, elev, mag;
526 < FVECT  vc;
524 > void
525 > moveview(                                       /* move viewpoint */
526 >        double  angle,
527 >        double  elev,
528 >        double  mag,
529 >        FVECT  vc
530 > )
531   {
372        extern double  sqrt(), dist2();
532          double  d;
533 <        FVECT  v1;
534 <        VIEW  nv;
376 <        register int  i;
533 >        VIEW  nv = ourview;
534 >        int  i;
535  
378        VCOPY(nv.vup, ourview.vup);
379        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
536          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
537 <        if (elev != 0.0) {
538 <                fcross(v1, ourview.vup, nv.vdir);
539 <                normalize(v1);
540 <                spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
541 <        }
542 <        if ((nv.type = ourview.type) == VT_PAR) {
387 <                nv.horiz = ourview.horiz / mag;
388 <                nv.vert = ourview.vert / mag;
537 >        if (elev != 0.0)
538 >                geodesic(nv.vdir, nv.vdir, nv.vup, elev*(-PI/180.), GEOD_RAD);
539 >
540 >        if (nv.type == VT_PAR) {
541 >                nv.horiz /= mag;
542 >                nv.vert /= mag;
543                  d = 0.0;                        /* don't move closer */
544                  for (i = 0; i < 3; i++)
545                          d += (vc[i] - ourview.vp[i])*ourview.vdir[i];
546          } else {
393                nv.horiz = ourview.horiz;
394                nv.vert = ourview.vert;
547                  d = sqrt(dist2(ourview.vp, vc)) / mag;
548 +                if (nv.vfore > FTINY) {
549 +                        nv.vfore += d - d*mag;
550 +                        if (nv.vfore < 0.0) nv.vfore = 0.0;
551 +                }
552 +                if (nv.vaft > FTINY) {
553 +                        nv.vaft += d - d*mag;
554 +                        if (nv.vaft <= nv.vfore) nv.vaft = 0.0;
555 +                }
556 +                nv.vdist /= mag;
557          }
558          for (i = 0; i < 3; i++)
559                  nv.vp[i] = vc[i] - d*nv.vdir[i];
# Line 400 | Line 561 | FVECT  vc;
561   }
562  
563  
564 < spinvector(vres, vorig, vnorm, theta)   /* rotate vector around normal */
565 < FVECT  vres, vorig, vnorm;
566 < double  theta;
564 > void
565 > pcopy(                                  /* copy paint node p1 into p2 */
566 >        PNODE  *p1,
567 >        PNODE  *p2
568 > )
569   {
570 <        extern double  sin(), cos();
571 <        double  sint, cost, dotp;
572 <        FVECT  vperp;
573 <        register int  i;
574 <        
575 <        if (theta == 0.0) {
576 <                VCOPY(vres, vorig);
570 >        copycolor(p2->v, p1->v);
571 >        p2->x = p1->x;
572 >        p2->y = p1->y;
573 > }
574 >
575 >
576 > void
577 > zoomview(                               /* zoom in or out */
578 >        VIEW  *vp,
579 >        double  zf
580 > )
581 > {
582 >        switch (vp->type) {
583 >        case VT_PAR:                            /* parallel view */
584 >                vp->horiz /= zf;
585 >                vp->vert /= zf;
586                  return;
587 +        case VT_ANG:                            /* angular fisheye */
588 +                vp->horiz /= zf;
589 +                if (vp->horiz > 360.)
590 +                        vp->horiz = 360.;
591 +                vp->vert /= zf;
592 +                if (vp->vert > 360.)
593 +                        vp->vert = 360.;
594 +                return;
595 +        case VT_PLS:                            /* planisphere fisheye */
596 +                vp->horiz = sin((PI/180./2.)*vp->horiz) /
597 +                                (1.0 + cos((PI/180./2.)*vp->horiz)) / zf;
598 +                vp->horiz *= vp->horiz;
599 +                vp->horiz = (2.*180./PI)*acos((1. - vp->horiz) /
600 +                                                (1. + vp->horiz));
601 +                vp->vert = sin((PI/180./2.)*vp->vert) /
602 +                                (1.0 + cos((PI/180./2.)*vp->vert)) / zf;
603 +                vp->vert *= vp->vert;
604 +                vp->vert = (2.*180./PI)*acos((1. - vp->vert) /
605 +                                                (1. + vp->vert));
606 +                return;
607 +        case VT_CYL:                            /* cylindrical panorama */
608 +                vp->horiz /= zf;
609 +                if (vp->horiz > 360.)
610 +                        vp->horiz = 360.;
611 +                vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / (PI/180./2.);
612 +                return;
613 +        case VT_PER:                            /* perspective view */
614 +                vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) /
615 +                                (PI/180./2.);
616 +                vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) /
617 +                                (PI/180./2.);
618 +                return;
619 +        case VT_HEM:                            /* hemispherical fisheye */
620 +                vp->horiz = sin(vp->horiz*(PI/180./2.))/zf;
621 +                if (vp->horiz >= 1.0-FTINY)
622 +                        vp->horiz = 180.;
623 +                else
624 +                        vp->horiz = asin(vp->horiz) / (PI/180./2.);
625 +                vp->vert = sin(vp->vert*(PI/180./2.))/zf;
626 +                if (vp->vert >= 1.0-FTINY)
627 +                        vp->vert = 180.;
628 +                else
629 +                        vp->vert = asin(vp->vert) / (PI/180./2.);
630 +                return;
631          }
416        sint = sin(theta);
417        cost = cos(theta);
418        dotp = DOT(vorig, vnorm);
419        fcross(vperp, vnorm, vorig);
420        for (i = 0; i < 3; i++)
421                vres[i] = vnorm[i]*dotp*(1.-cost) +
422                                vorig[i]*cost + vperp[i]*sint;
632   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines