558 |
|
SDmultiSamp(outVec, 2, randX); |
559 |
|
SDsquare2disk(outVec, outVec[0], outVec[1]); |
560 |
|
outVec[2] = 1. - outVec[0]*outVec[0] - outVec[1]*outVec[1]; |
561 |
< |
if (outVec[2] > 0) /* a bit of paranoia */ |
562 |
< |
outVec[2] = sqrt(outVec[2]); |
561 |
> |
outVec[2] = sqrt(outVec[2]*(outVec[2]>0)); |
562 |
|
if (!outFront) /* going out back? */ |
563 |
|
outVec[2] = -outVec[2]; |
564 |
|
} |
789 |
|
randX -= sd->tLamb.cieY; |
790 |
|
} |
791 |
|
/* else one of cumulative dist. */ |
792 |
< |
for (i = 0; i < n && randX < cdarr[i]->cTotal; i++) |
792 |
> |
for (i = 0; i < n && randX > cdarr[i]->cTotal; i++) |
793 |
|
randX -= cdarr[i]->cTotal; |
794 |
|
if (i >= n) |
795 |
|
return SDEinternal; |