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

Comparing ray/src/rt/ambio.c (file contents):
Revision 2.2 by greg, Thu Jul 16 12:08:47 1992 UTC vs.
Revision 2.3 by greg, Tue May 28 13:42:46 1996 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "color.h"
14  
15 + #include "fvect.h"
16 +
17   #include "ambient.h"
18  
19  
# Line 19 | Line 21 | static char SCCSid[] = "$SunId$ LBL";
21  
22   #define  getvec(v,fp)   (v)[0]=getflt(fp);(v)[1]=getflt(fp);(v)[2]=getflt(fp)
23  
24 + #define  badflt(x)      ((x) < -FHUGE || (x) > FHUGE)
25  
26 + #define  badvec(v)      (badflt((v)[0]) || badflt((v)[1]) || badflt((v)[2]))
27 +
28 +
29   extern double  getflt();
30   extern long  getint();
31  
# Line 63 | Line 69 | FILE  *fp;
69   }
70  
71  
72 + int
73 + ambvalOK(av)                    /* check consistency of ambient value */
74 + register AMBVAL  *av;
75 + {
76 +        double  d;
77 +
78 +        if (badvec(av->pos)) return(0);
79 +        if (badvec(av->dir)) return(0);
80 +        d = DOT(av->dir,av->dir);
81 +        if (d < 0.9999 || d > 1.0001) return(0);
82 +        if (av->lvl < 0 || av->lvl > 100) return(0);
83 +        if (av->weight <= 0. || av->weight > 1.) return(0);
84 +        if (av->rad <= 0. || av->rad >= FHUGE) return(0);
85 +        if (colval(av->val,RED) < 0. ||
86 +                        colval(av->val,RED) > FHUGE ||
87 +                        colval(av->val,GRN) < 0. ||
88 +                        colval(av->val,GRN) > FHUGE ||
89 +                        colval(av->val,BLU) < 0. ||
90 +                        colval(av->val,BLU) > FHUGE) return(0);
91 +        if (badvec(av->gpos)) return(0);
92 +        if (badvec(av->gdir)) return(0);
93 +        return(1);
94 + }
95 +
96 +
97   readambval(av, fp)              /* read ambient value from stream */
98   register AMBVAL  *av;
99   FILE  *fp;
# Line 81 | Line 112 | FILE  *fp;
112          av->rad = getflt(fp);
113          getvec(av->gpos, fp);
114          getvec(av->gdir, fp);
115 <        return(feof(fp) ? 0 : 1);
115 >        return(feof(fp) ? 0 : ambvalOK(av));
116   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines