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

Comparing ray/src/common/modobject.c (file contents):
Revision 2.13 by greg, Sat Mar 9 18:53:05 2013 UTC vs.
Revision 2.14 by greg, Sun Dec 8 18:59:53 2013 UTC

# Line 88 | Line 88 | object(                                /* get an object number from its name */
88   #endif
89  
90  
91 + static int
92 + eqreal(                         /* are two real values close enough to equal? */
93 +        double  d1,
94 +        double  d2
95 + )
96 + {
97 +        if (d2 != 0.0)
98 +                d1 = d1/d2 - 1.0;
99 +        return((-FTINY <= d1) & (d1 <= FTINY));
100 + }
101 +
102 +
103 + int
104 + eqobjects(                      /* check if two objects are equal */
105 +        OBJECT  obj1,
106 +        OBJECT  obj2
107 + )
108 + {
109 +        OBJREC  *op1, *op2;
110 +        int     i;
111 +
112 +        if (obj1 == OVOID)
113 +                return(obj2 == OVOID);
114 +        if (obj2 == OVOID)
115 +                return(0);
116 +        op1 = objptr(obj1);
117 +        op2 = objptr(obj2);
118 +        if (op1->omod != op2->omod)
119 +                return(0);
120 +        if (op1->otype != op2->otype)
121 +                return(0);
122 +        if (strcmp(op1->oname, op2->oname))
123 +                return(0);
124 +        if (op1->oargs.nsargs != op2->oargs.nsargs)
125 +                return(0);
126 +        if (op1->oargs.nfargs != op2->oargs.nfargs)
127 +                return(0);
128 + #ifdef IARGS
129 +        if (op1->oargs.niargs != op2->oargs.niargs)
130 +                return(0);
131 +        for (i = op1->oargs.niargs; i-- > 0; )
132 +                if (op1->oargs.iarg[i] != op2->oargs.iarg[i])
133 +                        return(0);
134 + #endif
135 +        for (i = op1->oargs.nfargs; i-- > 0; )
136 +                if (!eqreal(op1->oargs.farg[i], op2->oargs.farg[i]))
137 +                        return(0);
138 +        for (i = op1->oargs.nsargs; i-- > 0; )
139 +                if (strcmp(op1->oargs.sarg[i], op2->oargs.sarg[i]))
140 +                        return(0);
141 +        return(1);
142 + }
143 +
144 +
145   void
146   insertobject(                   /* insert new object into our list */
147          OBJECT  obj
# Line 97 | Line 151 | insertobject(                  /* insert new object into our list */
151  
152          if (ismodifier(objptr(obj)->otype)) {
153                  i = otndx(objptr(obj)->oname, &modtab);
154 +                if (eqobjects(obj, modtab.htab[i]))
155 +                        return;
156                  modtab.htab[i] = obj;
157          }
158   #ifdef  GETOBJ

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines