444 |
|
} |
445 |
|
|
446 |
|
typedef union {int i; double d; COLOR C;} *MyUptr; |
447 |
+ |
#define FEQ(x,y) (fabs((x)-(y)) <= FTINY) |
448 |
|
|
449 |
|
int |
450 |
|
getparam( /* get variable from user */ |
469 |
|
if (sscanf(buf, "%d", &i0) != 1) |
470 |
|
return(0); |
471 |
|
} |
472 |
+ |
if (ptr->i == i0) |
473 |
+ |
return(0); |
474 |
|
ptr->i = i0; |
475 |
|
break; |
476 |
|
case 'r': /* real */ |
482 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
483 |
|
return(0); |
484 |
|
} |
485 |
+ |
if (FEQ(ptr->d, d0)) |
486 |
+ |
return(0); |
487 |
|
ptr->d = d0; |
488 |
|
break; |
489 |
|
case 'b': /* boolean */ |
492 |
|
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
493 |
|
(*dev->comout)(buf); |
494 |
|
(*dev->comin)(buf, NULL); |
495 |
< |
if (buf[0] == '\0' || |
491 |
< |
strchr("yY+1tTnN-0fF", buf[0]) == NULL) |
495 |
> |
if (buf[0] == '\0') |
496 |
|
return(0); |
497 |
|
} |
498 |
< |
ptr->i = strchr("yY+1tT", buf[0]) != NULL; |
498 |
> |
if (strchr("yY+1tTnN-0fF", buf[0]) == NULL) |
499 |
> |
return(0); |
500 |
> |
i0 = strchr("yY+1tT", buf[0]) != NULL; |
501 |
> |
if (ptr->i == i0) |
502 |
> |
return(0); |
503 |
> |
ptr->i = i0; |
504 |
|
break; |
505 |
|
case 'C': /* color */ |
506 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
514 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
515 |
|
return(0); |
516 |
|
} |
517 |
+ |
if (FEQ(colval(ptr->C,RED), d0) && |
518 |
+ |
FEQ(colval(ptr->C,GRN), d1) && |
519 |
+ |
FEQ(colval(ptr->C,BLU), d2)) |
520 |
+ |
return(0); |
521 |
|
setcolor(ptr->C, d0, d1, d2); |
522 |
|
break; |
523 |
|
default: |
739 |
|
return; |
740 |
|
} |
741 |
|
|
742 |
< |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
730 |
< |
|
731 |
< |
rayvalue(&thisray); |
742 |
> |
ray_trace(&thisray); |
743 |
|
|
744 |
|
if (thisray.ro == NULL) |
745 |
|
(*dev->comout)("ray hit nothing"); |