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

Comparing ray/src/util/ranimove1.c (file contents):
Revision 3.9 by greg, Thu May 13 15:45:43 2004 UTC vs.
Revision 3.16 by greg, Fri Nov 5 04:36:24 2010 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   *  ranimove1.c
6   *
7 < *  Basic frame rendering routines for ranimate(1).
7 > *  Basic frame rendering routines for ranimove(1).
8   *
9   *  Created by Gregory Ward on Wed Jan 08 2003.
10   */
# Line 54 | Line 54 | static void setmotion(int      n, FVECT        wpos);
54   static void init_frame_sample(void);
55  
56  
57 + #if 0
58   extern void
59   write_map(              /* write out float map (debugging) */
60          float   *mp,
# Line 79 | Line 80 | write_map(             /* write out float map (debugging) */
80          }
81          fclose(fp);
82   }
83 + #endif
84  
85  
86   static void
# Line 105 | Line 107 | next_frame(void)                       /* prepare next frame buffer */
107                  error(USER, errmsg);
108          }
109          if (cbuffer == NULL) {
110 +                int     n;
111                                          /* compute resolution and allocate */
112                  switch (sscanf(vval(RESOLUTION), "%d %d %lf",
113                                  &hres, &vres, &pixaspect)) {
# Line 140 | Line 143 | next_frame(void)                       /* prepare next frame buffer */
143                                  (cprev==NULL) | (zprev == NULL) |
144                                  (oprev==NULL) | (aprev==NULL))
145                          error(SYSTEM, "out of memory in init_frame");
146 +                for (n = hres*vres; n--; ) {
147 +                        zprev[n] = -1.f;
148 +                        oprev[n] = OVOID;
149 +                }
150                  frm_stop = getTime() + rtperfrm;
151          } else {
152                  COLOR   *cp;            /* else just swap buffers */
# Line 367 | Line 374 | init_frame_sample(void)                /* sample our initial frame *
374                          continue;
375                  }
376                  if (!sample_here(x, y)) {       /* just cast */
377 <                        rayorigin(&ir, NULL, PRIMARY, 1.0);
377 >                        rayorigin(&ir, PRIMARY, NULL, NULL);
378                          if (!localhit(&ir, &thescene)) {
379 <                                if (ir.ro != &Aftplane)
380 <                                        sourcehit(&ir);
379 >                                if (ir.ro != &Aftplane && sourcehit(&ir)) {
380 >                                        rayshade(&ir, ir.ro->omod);
381 >                                        rayparticipate(&ir);
382 >                                }
383                                  copycolor(cbuffer[n], ir.rcol);
384                                  zbuffer[n] = ir.rot;
385                                  obuffer[n] = ir.robj;
# Line 385 | Line 394 | init_frame_sample(void)                /* sample our initial frame *
394                  }
395                  if (nprocs > 1) {               /* get sample */
396                          int     rval;
397 <                        rayorigin(&ir, NULL, PRIMARY, 1.0);
397 >                        rayorigin(&ir, PRIMARY, NULL, NULL);
398                          ir.rno = n;
399                          rval = ray_pqueue(&ir);
400                          if (!rval)
# Line 399 | Line 408 | init_frame_sample(void)                /* sample our initial frame *
408                  zbuffer[n] = ir.rot;
409                  obuffer[n] = ir.robj;
410                  sbuffer[n] = 1;
411 <                if (ir.rot >= FHUGE)
411 >                if (ir.rot >= 0.99*FHUGE)
412                          abuffer[n] = ADISTANT;
413                  else {
414                          abuffer[n] = ALOWQ;
# Line 452 | Line 461 | getambcolor(           /* get ambient color for object if we ca
461  
462          if (obj == OVOID)
463                  return(0);
464 <        op = objptr(obj);
465 <        if ((op->otype == OBJ_INSTANCE) & (op->omod == OVOID))
464 >        op = objptr(obj);               /* search for material */
465 >        if (op->omod == OVOID)
466                  return(0);
467 <                                        /* search for material */
468 <        do {
469 <                if (op->omod == OVOID || ofun[op->otype].flags & T_X)
461 <                        return(0);
462 <                op = objptr(op->omod);
463 <        } while (!ismaterial(op->otype));
467 >        op = findmaterial(objptr(op->omod));
468 >        if (op == NULL)
469 >                return(0);
470          /*
471           * Since this routine is called to compute the difference
472           * from rendering with and without interreflections,
# Line 474 | Line 480 | getambcolor(           /* get ambient color for object if we ca
480                          if (lv[0] == op->oname[0] &&
481                                          !strcmp(lv+1, op->oname+1))
482                                  break;
483 <                if ((lv != NULL) != hirendparams.ambincl)
483 >                if ((lv != NULL) ^ hirendparams.ambincl)
484                          return(0);
485          }
486          switch (op->otype) {
# Line 658 | Line 664 | extern void
664   init_frame(void)                        /* render base (low quality) frame */
665   {
666          int     restart;
661
667                                          /* allocate/swap buffers */
668          next_frame();
669                                          /* check rendering status */
670          restart = (!nobjects || vdef(MOVE));
671          if (!restart && curparams != &lorendparams && nprocs > 1)
672                  restart = -1;
668        if (restart > 0) {
669                if (nprocs > 1)
670                        ray_pdone(1);
671                else
672                        ray_done(1);
673        }
673                                          /* post low quality parameters */
674          if (curparams != &lorendparams)
675                  ray_restore(curparams = &lorendparams);
# Line 702 | Line 701 | init_frame(void)                       /* render base (low quality) frame
701          init_frame_sample();
702                                          /* initialize frame error */
703          comp_frame_error();
704 < return;
704 > #if 0
705   {
706          float   *ebuf = (float *)malloc(sizeof(float)*hres*vres);
707          char    fnm[256];
# Line 714 | Line 713 | return;
713          write_map(ebuf, fnm);
714          free((void *)ebuf);
715   }
716 + #endif
717   }
718  
719  
# Line 762 | Line 762 | filter_frame(void)                     /* interpolation, motion-blur, an
762                          continue;
763                  nc = getclosest(neigh, NPINTERP, x, y);
764                  setcolor(cbuffer[n], 0., 0., 0.);
765 +                if (nc <= 0) {          /* no acceptable neighbors */
766 +                        if (y < vres-1)
767 +                                nc = fndx(x, y+1);
768 +                        else if (x < hres-1)
769 +                                nc = fndx(x+1, y);
770 +                        else
771 +                                continue;
772 +                        copycolor(cbuffer[n], cbuffer[nc]);
773 +                        continue;
774 +                }
775                  wsum = 0.;
776                  while (nc-- > 0) {
777                          copycolor(cval, cbuffer[neigh[nc]]);
# Line 771 | Line 781 | filter_frame(void)                     /* interpolation, motion-blur, an
781                          addcolor(cbuffer[n], cval);
782                          wsum += w;
783                  }
784 <                if (wsum > FTINY) {
785 <                        w = 1.0/wsum;
776 <                        scalecolor(cbuffer[n], w);
777 <                }
784 >                w = 1.0/wsum;
785 >                scalecolor(cbuffer[n], w);
786              }
787                                          /* motion blur if requested */
788          if (mblur > .02) {
# Line 896 | Line 904 | send_frame(void)                       /* send frame to destination */
904          int     y;
905                                          /* open output picture */
906          sprintf(pfname, vval(BASENAME), fcur);
907 <        strcat(pfname, ".pic");
907 >        strcat(pfname, ".hdr");
908          fp = fopen(pfname, "w");
909          if (fp == NULL) {
910                  sprintf(errmsg, "cannot open output frame \"%s\"", pfname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines