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 2.35 by greg, Sat Oct 16 15:08:14 2010 UTC vs.
Revision 2.43 by greg, Thu Jan 23 19:20:54 2020 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13  
14   #include  "ray.h"
15   #include  "rpaint.h"
16 + #include  "otypes.h"
17 + #include  "otspecial.h"
18   #include  "random.h"
19  
20   #ifndef WFLUSH
# Line 29 | Line 31 | static const char      RCSid[] = "$Id$";
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
# Line 87 | Line 91 | getinterest(           /* get area of interest */
91          double  *mp
92   )
93   {
90        int  x, y;
91        RAY  thisray;
92        int  i;
93
94          if (sscanf(s, "%lf", mp) != 1)
95                  *mp = 1.0;
96          else if (*mp < -FTINY)          /* negative zoom is reduction */
# Line 100 | Line 100 | getinterest(           /* get area of interest */
100                  return(-1);
101          }
102          if (!sscanvec(sskip(s), vec)) {
103 +                RAY  thisray;
104 +                int  x, y;
105                  if (dev->getcur == NULL)
106                          return(-1);
107                  (*dev->comout)("Pick view center\n");
# Line 111 | Line 113 | getinterest(           /* get area of interest */
113                          return(-1);
114                  }
115                  if (!direc || ourview.type == VT_PAR) {
116 +                        int     weakhit = 0;
117 +                        FVECT   weakpt;
118                          rayorigin(&thisray, PRIMARY, NULL, NULL);
119 <                        if (!localhit(&thisray, &thescene)) {
120 <                                error(COMMAND, "not a local object");
121 <                                return(-1);
119 >                        while (localhit(&thisray, &thescene)) {
120 >                                OBJREC  *m = NULL;
121 >                                if (thisray.clipset == NULL ||
122 >                                                !inset(thisray.clipset,
123 >                                                            thisray.ro->omod))
124 >                                        m = findmaterial(thisray.ro);
125 >                                if ((m != NULL) & !weakhit &&
126 >                                                istransp(m->otype) &&
127 >                                                m->otype != MAT_MIST) {
128 >                                        weakhit = 1;
129 >                                        VCOPY(weakpt, thisray.rop);
130 >                                } else if (m != NULL && !istransp(m->otype) &&
131 >                                                !isBSDFproxy(m))
132 >                                        break;          /* something solid */
133 >                                VCOPY(thisray.rorg, thisray.rop);
134 >                                rayclear(&thisray);     /* skip invisible */
135                          }
136 +                        if ((thisray.ro == NULL) | (thisray.ro == &Aftplane)) {
137 +                                if (!weakhit) {
138 +                                        error(COMMAND, "not a local object");
139 +                                        return(-1);
140 +                                }                       /* else use weak obj. */
141 +                                VCOPY(thisray.rop, weakpt);
142 +                        }
143                  }
144                  if (direc)
145                          if (ourview.type == VT_PAR)
146 <                                for (i = 0; i < 3; i++)
123 <                                        vec[i] = thisray.rop[i] - ourview.vp[i];
146 >                                VSUB(vec, thisray.rop, ourview.vp);
147                          else
148                                  VCOPY(vec, thisray.rdir);
149                  else
150                          VCOPY(vec, thisray.rop);
151          } else if (direc) {
152 <                for (i = 0; i < 3; i++)
130 <                        vec[i] -= ourview.vp[i];
152 >                VSUB(vec, vec, ourview.vp);
153                  if (normalize(vec) == 0.0) {
154                          error(COMMAND, "point at view origin");
155                          return(-1);
# Line 137 | Line 159 | getinterest(           /* get area of interest */
159   }
160  
161  
162 < float *         /* keep consistent with COLOR typedef */
162 > COLORV *
163   greyof(                         /* convert color to greyscale */
164          COLOR  col
165   )
# Line 192 | Line 214 | paint(                 /* compute and paint a rectangle */
214          if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
215                          h/hresolu, v/vresolu)) < -FTINY) {
216                  setcolor(thisray.rcol, 0.0, 0.0, 0.0);
217 <        } else if (nproc == 1) {                /* immediate mode */
217 >        } else if (!ray_pnprocs) {              /* immediate mode */
218                  ray_trace(&thisray);
219          } else {                                /* queuing mode */
220                  int     rval;
# Line 216 | Line 238 | paint(                 /* compute and paint a rectangle */
238                  static RNUMBER  lastflush = 0;
239                  RNUMBER         counter = raynum;
240                  int             flushintvl;
241 <                if (nproc == 1) {
241 >                if (!ray_pnprocs) {
242                          counter = nrays;
243                          flushintvl = WFLUSH1;
244                  } else if (ambounce == 0)
245 <                        flushintvl = nproc*WFLUSH;
245 >                        flushintvl = ray_pnprocs*WFLUSH;
246                  else if (niflush < WFLUSH)
247 <                        flushintvl = nproc*niflush/(ambounce+1);
247 >                        flushintvl = ray_pnprocs*niflush/(ambounce*(ambounce>0)+1);
248                  else
249 <                        flushintvl = nproc*WFLUSH/(ambounce+1);
249 >                        flushintvl = ray_pnprocs*WFLUSH/(ambounce*(ambounce>0)+1);
250                  if (lastflush > counter)
251                          lastflush = 0;          /* counter wrapped */
252  
# Line 245 | Line 267 | waitrays(void)                                 /* finish up pending rays */
267          int     rval;
268          RAY     raydone;
269  
270 <        if (nproc <= 1)                         /* immediate mode? */
270 >        if (!ray_pnprocs)                       /* immediate mode? */
271                  return(0);
272          while ((rval = ray_presult(&raydone, 0)) > 0) {
273                  PNODE  *p = (PNODE *)raydone.rno;
# Line 265 | Line 287 | newimage(                                      /* start a new image */
287          char *s
288   )
289   {
268        extern int      ray_pnprocs;
290          int             newnp = 0;
291                                                  /* # rendering procs arg? */
292          if (s != NULL)
# Line 284 | Line 305 | newimage(                                      /* start a new image */
305          (*dev->clear)(hresolu, vresolu);
306  
307          if (newparam) {                         /* (re)start rendering procs */
308 <                if (ray_pnprocs > 0)
309 <                        ray_pclose(0);
308 >                if (ray_pnprocs)
309 >                        ray_pclose(0);          /* should already be closed */
310                  if (newnp > 0)
311                          nproc = newnp;
312                  if (nproc > 1)
# Line 516 | Line 537 | moveview(                                      /* move viewpoint */
537   )
538   {
539          double  d;
519        FVECT  v1;
540          VIEW  nv = ourview;
541          int  i;
542  
543          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
544 <        if (elev != 0.0) {
545 <                fcross(v1, ourview.vup, nv.vdir);
546 <                normalize(v1);
527 <                spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
528 <        }
544 >        if (elev != 0.0)
545 >                geodesic(nv.vdir, nv.vdir, nv.vup, elev*(-PI/180.), GEOD_RAD);
546 >
547          if (nv.type == VT_PAR) {
548                  nv.horiz /= mag;
549                  nv.vert /= mag;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines