src/mcrt/photon_map.cc
// Beam into the k-d node regions trying to find photons which are inside a given sphere.
Beam into the k-d node regions trying to find photons which are inside a given sphere.
Beam into the k - d node regions trying to find photons which are inside a given sphere .
void mcrt::PhotonMap::KdNode::around(const glm::dvec3& sphereOrigin, double sphereRadius,
                                     std::vector<const Photon*>& photonsInSphere) const {
    double axisRadius { photon->position[axis] - sphereOrigin[axis] };
    if (axisRadius * axisRadius <= sphereRadius * sphereRadius) {
        if (left  != nullptr) left->around(sphereOrigin,  sphereRadius, photonsInSphere);
        if (right != nullptr) right->around(sphereOrigin, sphereRadius, photonsInSphere);
        if (glm::distance(sphereOrigin, photon->position) <= sphereRadius) {
            photonsInSphere.push_back(photon);
        }
    } else if (left != nullptr  && photon->position[axis] >  sphereOrigin[axis]) {
        left->around(sphereOrigin, sphereRadius, photonsInSphere);
    } else if (right != nullptr && photon->position[axis] <= sphereOrigin[axis]) {
        right->around(sphereOrigin, sphereRadius, photonsInSphere);
    }
}
void mcrt :: PhotonMap :: KdNode :: around ( const glm :: dvec3 & sphereOrigin , double sphereRadius , std :: vector < const Photon * > & photonsInSphere ) const { double axisRadius { photon -> position [ axis ] - sphereOrigin [ axis ] } ; if ( axisRadius * axisRadius <= sphereRadius * sphereRadius ) { if ( left != nullptr ) left -> around ( sphereOrigin , sphereRadius , photonsInSphere ) ; if ( right != nullptr ) right -> around ( sphereOrigin , sphereRadius , photonsInSphere ) ; if ( glm :: distance ( sphereOrigin , photon -> position ) <= sphereRadius ) { photonsInSphere . push_back ( photon ) ; } } else if ( left != nullptr && photon -> position [ axis ] > sphereOrigin [ axis ] ) { left -> around ( sphereOrigin , sphereRadius , photonsInSphere ) ; } else if ( right != nullptr && photon -> position [ axis ] <= sphereOrigin [ axis ] ) { right -> around ( sphereOrigin , sphereRadius , photonsInSphere ) ; } }
Beam into the k-d node regions trying to find photons which are inside a given sphere.
Beam into the k - d node regions trying to find photons which are inside a given sphere .