| 207 |  | coef = 1.0; | 
| 208 |  | else if (coef < 0.0) | 
| 209 |  | coef = 0.0; | 
| 210 | + | /* compute foreground and background */ | 
| 211 | + | foremat = backmat = -1; | 
| 212 |  | /* foreground */ | 
| 213 |  | copystruct(&fr, r); | 
| 214 |  | if (fore != OVOID && coef > FTINY) | 
| 215 |  | foremat = rayshade(&fr, fore); | 
| 214 | – | else | 
| 215 | – | foremat = 0; | 
| 216 |  | /* background */ | 
| 217 |  | copystruct(&br, r); | 
| 218 |  | if (back != OVOID && coef < 1.0-FTINY) | 
| 219 |  | backmat = rayshade(&br, back); | 
| 220 | – | else | 
| 221 | – | backmat = foremat; | 
| 220 |  | /* check */ | 
| 221 | + | if (foremat < 0) | 
| 222 | + | if (backmat < 0) | 
| 223 | + | foremat = backmat = 0; | 
| 224 | + | else | 
| 225 | + | foremat = backmat; | 
| 226 | + | else if (backmat < 0) | 
| 227 | + | backmat = foremat; | 
| 228 |  | if ((foremat==0) != (backmat==0)) | 
| 229 |  | objerror(r->ro, USER, "mixing material with non-material"); | 
| 230 |  | /* mix perturbations */ |