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

Comparing ray/src/common/ccolor.c (file contents):
Revision 3.10 by greg, Wed Apr 5 00:54:50 2017 UTC vs.
Revision 3.11 by greg, Thu Apr 13 00:42:01 2017 UTC

# Line 238 | Line 238 | c_ccvt(C_COLOR *clr, int fl)
238                  y /= (double)c_y31.ssum;
239                  z /= (double)c_z31.ssum;
240                  z += x + y;
241 <                clr->cx = x / z;
242 <                clr->cy = y / z;
241 >                if (z > 1e-6) {
242 >                        clr->cx = x / z;
243 >                        clr->cy = y / z;
244 >                } else
245 >                        clr->cx = clr->cy = 1./3.;
246                  clr->flags |= C_CSXY;
247          }
248          if (fl & C_CSSPEC) {            /* cxy -> cspec */
# Line 262 | Line 265 | c_ccvt(C_COLOR *clr, int fl)
265                          y = 0.;
266                          for (i = 0; i < C_CNSS; i++)
267                                  y += c_y31.ssamp[i] * clr->ssamp[i];
268 <                        clr->eff = C_CLPWM * y / clr->ssum;
268 >                        clr->eff = C_CLPWM * y / (clr->ssum + 0.0001);
269                  } else /* clr->flags & C_CSXY */ {      /* from (x,y) */
270                          clr->eff = clr->cx*c_x31.eff + clr->cy*c_y31.eff +
271                                          (1. - clr->cx - clr->cy)*c_z31.eff;
# Line 278 | Line 281 | c_cmix(C_COLOR *cres, double w1, C_COLOR *c1, double w
281          double  scale;
282          int     i;
283  
284 +        if (w1 == 0) {
285 +                *cres = *c2;
286 +                return;
287 +        }
288 +        if (w2 == 0) {
289 +                *cres = *c1;
290 +                return;
291 +        }
292          if ((c1->flags|c2->flags) & C_CDSPEC) {         /* spectral mixing */
293                  float   cmix[C_CNSS];
294  
295                  c_ccvt(c1, C_CSSPEC|C_CSEFF);
296                  c_ccvt(c2, C_CSSPEC|C_CSEFF);
297 +                if (c1->ssum*c2->ssum == 0) {
298 +                        *cres = c_dfcolor;
299 +                        return;
300 +                }
301                  w1 /= c1->eff*c1->ssum;
302                  w2 /= c2->eff*c2->ssum;
303                  scale = 0.;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines