8#include <Common/assertion.h>
9#include <Common/primitive_type.h>
10#include <Common/logging.h>
22template<CPhoton Photon>
43 static_assert(std::is_base_of_v<TPhoton<Photon>, Photon>);
47 static_assert(Photon::template has<EPhotonData::Pos>());
49 return photon.template get<EPhotonData::Pos>();
79 const std::size_t viewPathLength,
80 const std::size_t minFullPathLength,
81 const std::size_t maxFullPathLength)
const
83 PH_ASSERT_LE(minFullPathLength, maxFullPathLength);
84 const auto minFullPathLengthFromMap = viewPathLength +
minPathLength;
85 const auto maxFullPathLengthFromMap = viewPathLength +
maxPathLength;
86 return maxFullPathLength >= minFullPathLengthFromMap &&
87 minFullPathLength <= maxFullPathLengthFromMap;
94 const real kernelRadius,
95 std::vector<Photon>& photons)
const
105 const real kernelRadius,
106 const std::size_t viewPathLength,
107 const std::size_t minFullPathLength,
108 const std::size_t maxFullPathLength,
109 std::vector<Photon>& photons)
const
111 if(!
canContribute(viewPathLength, minFullPathLength, maxFullPathLength))
116 if constexpr(Photon::template has<EPhotonData::PathLength>())
118 const auto kernelRadius2 = kernelRadius * kernelRadius;
124 this, kernelRadius2, viewPathLength, minFullPathLength, maxFullPathLength,
127 (
const Photon& photon)
130 const auto dist2 = (pos - position).lengthSquared();
131 const auto fullPathLen = viewPathLength + photon.template get<EPhotonData::PathLength>();
132 if(dist2 < kernelRadius2 &&
133 minFullPathLength <= fullPathLen && fullPathLen <= maxFullPathLength)
135 photons.push_back(photon);
142 PH_DEFAULT_LOG(ErrorOnce,
143 "The photon type in this photon map contains no path length info. Cannot find "
144 "photon for the specified full path length in [{}, {}]. This photon map "
145 "contains path length in [{}, {}].",
static constexpr uint32 DEFAULT_MAX_PATH_LENGTH
Definition PMCommonParams.h:15
Default photon map type. Should be adequate for most cases.
Definition TPhotonMap.h:39
uint32 maxPathLength
Definition TPhotonMap.h:70
uint32 minPathLength
Definition TPhotonMap.h:65
math::TIndexedPointKdtree< Photon, uint32, PhotonCenterCalculator, PhotonStorage > MapType
Definition TPhotonMap.h:53
bool canContribute(const std::size_t viewPathLength, const std::size_t minFullPathLength, const std::size_t maxFullPathLength) const
Definition TPhotonMap.h:78
MapType map
Definition TPhotonMap.h:56
TPhotonMapInfo< Photon > getInfo() const
Definition TPhotonMap.h:150
void find(const math::Vector3R &position, const real kernelRadius, std::vector< Photon > &photons) const
Find all photons in a radius.
Definition TPhotonMap.h:92
void find(const math::Vector3R &position, const real kernelRadius, const std::size_t viewPathLength, const std::size_t minFullPathLength, const std::size_t maxFullPathLength, std::vector< Photon > &photons) const
Find all photons in a radius that can contribute given the path requirements.
Definition TPhotonMap.h:103
std::size_t numPaths
Definition TPhotonMap.h:60
Carries common informatiom for a photon map.
Definition TPhotonMap.h:24
uint32 minPathLength
Definition TPhotonMap.h:27
std::size_t numPaths
Definition TPhotonMap.h:26
uint32 maxPathLength
Definition TPhotonMap.h:28
Definition TIndexedPointKdtree.h:42
void findWithinRange(const math::Vector3R &location, const real searchRadius, std::vector< Item > &results) const
Definition TIndexedPointKdtree.h:120
void rangeTraversal(const math::Vector3R &location, const real squaredSearchRadius, ItemHandler itemHandler) const
Definition TIndexedPointKdtree.h:232
Definition TIndexedPointKdtree.h:25
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TPhotonMap.h:42
math::Vector3R operator()(const Photon &photon) const
Definition TPhotonMap.h:45
Definition TIndexedPointKdtree.h:47