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.15 by greg, Sun Dec 8 19:25:36 2013 UTC

# Line 88 | Line 88 | object(                                /* get an object number from its name */
88   #endif
89  
90  
91 + 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 +        while (obj1 != obj2) {
113 +                if (obj1 == OVOID)
114 +                        return(0);
115 +                if (obj2 == OVOID)
116 +                        return(0);
117 +                op1 = objptr(obj1);
118 +                op2 = objptr(obj2);
119 +                if (op1->otype != op2->otype)
120 +                        return(0);
121 +                if (op1->oargs.nsargs != op2->oargs.nsargs)
122 +                        return(0);
123 +                if (op1->oargs.nfargs != op2->oargs.nfargs)
124 +                        return(0);
125 + #ifdef IARGS
126 +                if (op1->oargs.niargs != op2->oargs.niargs)
127 +                        return(0);
128 +                for (i = op1->oargs.niargs; i-- > 0; )
129 +                        if (op1->oargs.iarg[i] != op2->oargs.iarg[i])
130 +                                return(0);
131 + #endif
132 +                for (i = op1->oargs.nfargs; i-- > 0; )
133 +                        if (!eqreal(op1->oargs.farg[i], op2->oargs.farg[i]))
134 +                                return(0);
135 +                for (i = op1->oargs.nsargs; i-- > 0; )
136 +                        if (strcmp(op1->oargs.sarg[i], op2->oargs.sarg[i]))
137 +                                return(0);
138 +                obj1 = op1->omod;
139 +                obj2 = op2->omod;
140 +        }
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