Kdtree Lookup: PBRT Source Code

304 Views Asked by At

I am trying to implement a kdtree using the pbrt source code for finding the n closest points. I have an array of points distributed over the 3d space and I need to calculate the number of points that lie within a given distance from the reference point. So can someone guide me on how do I proceed? Basically, I am using the same lookup process (PhotonProcess) as that is mentioned in integrators/photonmap.cpp. But somehow I end up getting weird results. Here is a small part of the code that I am using.

const uint32_t nAbsorptionPhotons = 10;         //photons to be found
PhotonProcess proc(nAbsorptionPhotons,arena.Alloc<ClosePhoton>(nAbsorptionPhotons));
float searchDist = 0.f;
Photon p;
p.p.x = 50;    //just a reference point set arbitrarily to 50
p.p.y = 50;
p.p.z = 50;
searchDist = 0;

while (proc.nFound < nAbsorptionPhotons) {
            float md2 = searchDist;
            AbsorptionMap->Lookup(p.p, proc, md2);
            searchDist += 1.f;

      }    
printf("SearchDistance is %f \n", searchDist);

I am not getting the expected value of searchdist. Any hints ideas or suggestions are welcome.

0

There are 0 best solutions below