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

Comparing ray/src/rt/ambient.c (file contents):
Revision 1.8 by greg, Fri Jan 12 11:30:59 1990 UTC vs.
Revision 1.11 by greg, Fri Sep 7 08:17:42 1990 UTC

# Line 34 | Line 34 | extern int  ambounce;          /* number of ambient bounces */
34   extern char  *amblist[];        /* ambient include/exclude list */
35   extern int  ambincl;            /* include == 1, exclude == 0 */
36  
37 < OBJECT  ambset[256]={0};        /* ambient include/exclude set */
37 > #define  MAXASET        511     /* maximum number of elements in ambient set */
38 > OBJECT  ambset[MAXASET+1]={0};  /* ambient include/exclude set */
39  
40   double  maxarad;                /* maximum ambient radius */
41   double  minarad;                /* minimum ambient radius */
# Line 76 | Line 77 | setambient(afile)                      /* initialize calculation */
77   char  *afile;
78   {
79          long  ftell();
79        OBJECT  obj;
80          AMBVAL  amb;
81  
82          maxarad = thescene.cusize / 2.0;                /* maximum radius */
# Line 86 | Line 86 | char  *afile;
86                                          /* open ambient file */
87          if (afile != NULL)
88                  if ((ambfp = fopen(afile, "r+")) != NULL) {
89 <                        while (fread(&amb, sizeof(AMBVAL), 1, ambfp) == 1)
89 >                        while (fread((char *)&amb,sizeof(AMBVAL),1,ambfp) == 1)
90                                  avinsert(&amb, &atrunk, thescene.cuorg,
91                                                  thescene.cusize);
92                                                          /* align */
# Line 102 | Line 102 | char  *afile;
102   ambnotify(obj)                  /* record new modifier */
103   OBJECT  obj;
104   {
105 +        static int  hitlimit = 0;
106          register OBJREC  *o = objptr(obj);
107          register char  **amblp;
108  
109 <        if (!ismodifier(o->otype))
109 >        if (hitlimit || !ismodifier(o->otype))
110                  return;
111          for (amblp = amblist; *amblp != NULL; amblp++)
112                  if (!strcmp(o->oname, *amblp)) {
113 +                        if (ambset[0] >= MAXASET) {
114 +                                error(WARNING, "too many modifiers in ambient list");
115 +                                hitlimit++;
116 +                                return;         /* should this be fatal? */
117 +                        }
118                          insertelem(ambset, obj);
119                          return;
120                  }
# Line 392 | Line 398 | register RAY  *r;
398                  dnew.k = b2/(dnew.n*dnew.n);
399                                                  /* reinsert */
400                  for (k = 0; k < ne-1 && dnew.k < div[k+1].k; k++)
401 <                        bcopy(&div[k+1], &div[k], sizeof(AMBSAMP));
402 <                bcopy(&dnew, &div[k], sizeof(AMBSAMP));
401 >                        copystruct(&div[k], &div[k+1]);
402 >                copystruct(&div[k], &dnew);
403  
404                  if (ne >= i) {          /* extract darkest division */
405                          ne--;
# Line 438 | Line 444 | AMBVAL  *av;
444   #endif
445          if (ambfp == NULL)
446                  return;
447 <        if (fwrite(av, sizeof(AMBVAL), 1, ambfp) != 1)
447 >        if (fwrite((char *)av, sizeof(AMBVAL), 1, ambfp) != 1)
448                  goto writerr;
449   #ifdef  AMBFLUSH
450          if (++nunflshed >= AMBFLUSH) {
# Line 467 | Line 473 | double  s;
473  
474          if ((av = newambval()) == NULL)
475                  goto memerr;
476 <        bcopy(aval, av, sizeof(AMBVAL));
476 >        copystruct(av, aval);
477          VCOPY(ck0, c0);
478          while (s*(OCTSCALE/2) > av->rad*ambacc) {
479                  if (at->kid == NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines