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

Comparing ray/src/cv/mgflib/context.c (file contents):
Revision 1.20 by greg, Wed Apr 12 17:16:33 1995 UTC vs.
Revision 1.24 by greg, Wed Feb 12 11:38:52 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1997 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 105 | Line 105 | register char  **av;
105                          c_ccname = NULL;
106                          return(MG_OK);
107                  }
108 +                if (!isname(av[1]))
109 +                        return(MG_EILL);
110                  lp = lu_find(&clr_tab, av[1]);  /* lookup context */
111                  if (lp == NULL)
112                          return(MG_EMEM);
# Line 175 | Line 177 | register char  **av;
177                  if (!isflt(av[1]))
178                          return(MG_ETYPE);
179                  wsum = atof(av[1]);
178                if (wsum < 0.)
179                        return(MG_EILL);
180                  if ((lp = lu_find(&clr_tab, av[2])) == NULL)
181                          return(MG_EMEM);
182                  if (lp->data == NULL)
# Line 186 | Line 186 | register char  **av;
186                          if (!isflt(av[i]))
187                                  return(MG_ETYPE);
188                          w = atof(av[i]);
189                        if (w < 0.)
190                                return(MG_EILL);
189                          if ((lp = lu_find(&clr_tab, av[i+1])) == NULL)
190                                  return(MG_EMEM);
191                          if (lp->data == NULL)
# Line 196 | Line 194 | register char  **av;
194                                          w, (C_COLOR *)lp->data);
195                          wsum += w;
196                  }
197 +                if (wsum <= 0.)
198 +                        return(MG_EILL);
199                  c_ccolor->clock++;
200                  return(MG_OK);
201          }
# Line 221 | Line 221 | register char  **av;
221                          c_cmname = NULL;
222                          return(MG_OK);
223                  }
224 +                if (!isname(av[1]))
225 +                        return(MG_EILL);
226                  lp = lu_find(&mat_tab, av[1]);  /* lookup context */
227                  if (lp == NULL)
228                          return(MG_EMEM);
# Line 259 | Line 261 | register char  **av;
261                  *c_cmaterial = *(C_MATERIAL *)lp->data;
262                  c_cmaterial->clock = i + 1;
263                  return(MG_OK);
264 +        case MG_E_IR:           /* set index of refraction */
265 +                if (ac != 3)
266 +                        return(MG_EARGC);
267 +                if (!isflt(av[1]) | !isflt(av[2]))
268 +                        return(MG_ETYPE);
269 +                c_cmaterial->nr = atof(av[1]);
270 +                c_cmaterial->ni = atof(av[2]);
271 +                if (c_cmaterial->nr <= FTINY)
272 +                        return(MG_EILL);
273 +                c_cmaterial->clock++;
274 +                return(MG_OK);
275          case MG_E_RD:           /* set diffuse reflectance */
276                  if (ac != 2)
277                          return(MG_EARGC);
# Line 355 | Line 368 | register char  **av;
368                          c_cvname = NULL;
369                          return(MG_OK);
370                  }
371 +                if (!isname(av[1]))
372 +                        return(MG_EILL);
373                  lp = lu_find(&vtx_tab, av[1]);  /* lookup context */
374                  if (lp == NULL)
375                          return(MG_EMEM);
# Line 589 | Line 604 | char   **av;
604                  }
605                  if (n > 1)
606                          va[i] /= (double)n;
592                if (va[i] < 0.)
593                        return(MG_EILL);
607                  if (va[i] > scale)
608                          scale = va[i];
609 +                else if (va[i] < -scale)
610 +                        scale = -va[i];
611          }
612          if (scale <= FTINY)
613                  return(MG_EILL);
# Line 650 | Line 665 | double w1, w2;
665          } else {                                        /* CIE xy mixing */
666                  c_ccvt(c1, C_CSXY);
667                  c_ccvt(c2, C_CSXY);
668 <                scale = 1. / (w1/c1->cy + w2/c2->cy);
668 >                scale = w1/c1->cy + w2/c2->cy;
669 >                if (scale == 0.)
670 >                        return;
671 >                scale = 1. / scale;
672                  cres->cx = (c1->cx*w1/c1->cy + c2->cx*w2/c2->cy) * scale;
673                  cres->cy = (w1 + w2) * scale;
674                  cres->flags = C_CDXY|C_CSXY;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines