15 |
|
|
16 |
|
#include "pmapdata.h" /* Includes pmapkdt.h */ |
17 |
|
#include "source.h" |
18 |
+ |
#include "otspecial.h" |
19 |
+ |
#include "random.h" |
20 |
|
|
21 |
|
|
22 |
|
|
426 |
|
|
427 |
|
/* Photon pos & normal stored at lower precision */ |
428 |
|
VCOPY(p, pos); |
429 |
< |
VCOPY(n, norm); |
430 |
< |
kdT_FindNearest(pmap, p, n, 1); |
429 |
> |
if (norm) |
430 |
> |
VCOPY(n, norm); |
431 |
> |
kdT_FindNearest(pmap, p, norm ? n : NULL, 1); |
432 |
|
} |
433 |
|
|
434 |
|
|
467 |
|
d2 = DOT(dv, dv); |
468 |
|
|
469 |
|
if (d2 < pmap -> maxDist2 && |
470 |
< |
DOT(norm, p -> norm) > PMAP_NORM_TOL * 127 * frandom()) { |
470 |
> |
(!norm || DOT(norm, p -> norm) > PMAP_NORM_TOL * 127 * frandom())) { |
471 |
|
/* Closest photon so far with similar normal. We allow for tolerance |
472 |
|
* to account for perturbation in the latter; note the photon normal |
473 |
|
* is coded in the range [-127,127], hence we factor this in */ |
486 |
|
|
487 |
|
/* Photon pos & normal stored at lower precision */ |
488 |
|
VCOPY(p, pos); |
489 |
< |
VCOPY(n, norm); |
490 |
< |
kdT_Find1Nearest(pmap, p, n, &pnn, 1); |
489 |
> |
if (norm) |
490 |
> |
VCOPY(n, norm); |
491 |
> |
kdT_Find1Nearest(pmap, p, norm ? n : NULL, &pnn, 1); |
492 |
|
memcpy(photon, pnn, sizeof(Photon)); |
493 |
|
} |
494 |
|
|