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

Comparing ray/src/common/face.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:34:31 1989 UTC vs.
Revision 2.2 by greg, Fri Oct 2 16:02:20 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 34 | Line 34 | FACE *
34   getface(o)                      /* get arguments for a face */
35   OBJREC  *o;
36   {
37        double  fabs();
37          double  d1;
38          int  badvert;
39          FVECT  v1, v2, v3;
# Line 51 | Line 50 | OBJREC  *o;
50          if (o->oargs.nfargs < 9 || o->oargs.nfargs % 3)
51                  objerror(o, USER, "bad # arguments");
52  
53 +        o->os = (char *)f;                      /* save face */
54 +
55          f->va = o->oargs.farg;
56          f->nv = o->oargs.nfargs / 3;
57                                                  /* compute area and normal */
# Line 69 | Line 70 | OBJREC  *o;
70          f->area = normalize(f->norm);
71          if (f->area == 0.0) {
72                  objerror(o, WARNING, "zero area");      /* used to be fatal */
73 <                f->const = 0.0;
73 >                f->offset = 0.0;
74                  f->ax = 0;
75                  return(f);
76          }
77          f->area *= 0.5;
78 <                                                /* compute constant */
78 >                                                /* compute offset */
79          badvert = 0;
80 <        f->const = DOT(f->norm, VERTEX(f,0));
80 >        f->offset = DOT(f->norm, VERTEX(f,0));
81          for (i = 1; i < f->nv; i++) {
82                  d1 = DOT(f->norm, VERTEX(f,i));
83 <                badvert += fabs(d1 - f->const/i) > VERTEPS;
84 <                f->const += d1;
83 >                badvert += fabs(d1 - f->offset/i) > VERTEPS;
84 >                f->offset += d1;
85          }
86 <        f->const /= f->nv;
86 >        f->offset /= (double)f->nv;
87          if (badvert)
88                  objerror(o, WARNING, "non-planar vertex");
89                                                  /* find axis */
# Line 90 | Line 91 | OBJREC  *o;
91          if (fabs(f->norm[2]) > fabs(f->norm[f->ax]))
92                  f->ax = 2;
93  
93        (FACE *)o->os = f;                      /* save face */
94          return(f);
95   }
96  
# Line 98 | Line 98 | OBJREC  *o;
98   freeface(o)                     /* free memory associated with face */
99   OBJREC  *o;
100   {
101 +        if (o->os == NULL)
102 +                return;
103          free(o->os);
104          o->os = NULL;
105   }
# Line 110 | Line 112 | FACE  *f;
112          int  ncross, n;
113          double  x, y;
114          register int  xi, yi;
115 <        register double  *p0, *p1;
115 >        register FLOAT  *p0, *p1;
116  
117          xi = (f->ax+1)%3;
118          yi = (f->ax+2)%3;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines