39 template<
class SceneType,
class Vec3>
40 [[nodiscard]]
inline static std::optional<Vec3>
ReflectPoint(
const SceneType& scene,
44 template<
class Vec3,
class SceneType>
46 std::span<const int> triCache,
47 std::span<const Vec3> imageSources,
48 const Vec3& receiver);
51 template<
class Vec3,
class SceneType>
55 template<
class SceneType>
58 template<
class SceneType,
class OnISsReadyCallback>
59 static void ReconstructImageSources(
const SceneType& scene, std::span<const int> pathNodes,
const OnISsReadyCallback& callback);
71 template<
class SceneType,
class Vec3>
74 Vec3 planeNormal, planePoint;
75 if (scene.GetSurfacePlane(surfaceId, planeNormal, planePoint))
76 return Math::GetImageSource(point, planeNormal, planePoint);
81 template<
class Vec3,
class SceneType>
82 inline bool SceneInterface::ValidatePath(
const SceneType& scene, std::span<const int> triCache, std::span<const Vec3> imageSources,
const Vec3& receiver)
84 using Intersection =
typename SceneType::Intersection;
90 for (
auto i = imageSources.size() - 1; i >= 1; --i)
93 if (not scene.Intersect(R, imageSources[i], hit) || hit.SurfaceID != triCache[i])
97 static constexpr float offset = 0.001f;
99 R = hit.Position + hit.Normal * offset;
104 return not scene.IsOccluded(R, imageSources[0]);
107 template<
class Vec3,
class SceneType>
110 bool bPathValid =
false;
114 if (path.Nodes.size() - 1 != newImageSources.size())
125 for (
auto i = newImageSources.size() - 1; i >= 1; --i)
127 using Intersection = typename SceneType::Intersection;
130 if (not scene.Intersect(R, newImageSources[i], hit) || hit.SurfaceID != path.Nodes[i])
137 static constexpr float offset = 0.001f;
139 R = hit.Position + hit.Normal * offset;
144 bPathValid = not scene.IsOccluded(R, newImageSources[0]);
150 template<
class SceneType>
151 inline void SceneInterface::AccumulateMaterialAbsorption(
const SceneType& scene, std::span<const int> surfaces,
EnergyBands& outEnergyLoss)
154 for (
int surfaceId : surfaces)
157 if (scene.GetMaterialAbsorption(surfaceId, materialAbsorption))
158 outEnergyLoss += materialAbsorption;
162 template<
class SceneType,
class OnISsReadyCallback>
163 inline void SceneInterface::ReconstructImageSources(
const SceneType& scene, std::span<const int> pathNodes,
const OnISsReadyCallback& callback)
165 using Vec3 =
typename SceneType::Vec3;
167 const auto surfaces = pathNodes.subspan(0, pathNodes.size() - 1);
168 const Vec3 source = scene.GetSourcePosition(pathNodes.front());
169 const Vec3 receiver = scene.GetReceiverPosition(pathNodes.back());
176 for (
const int Tjd : surfaces | std::views::drop(1))
178 auto imageSource = ReflectPoint(scene, IS.
back(), Tjd);
181 if (imageSource.has_value())
194 callback(std::span<const Vec3>(IS), receiver);
#define JPL_ASSERT(inExpression,...)
Main assert macro, usage: JPL_ASSERT(condition, message) or JPL_ASSERT(condition)
Definition ErrorReporting.h:80
A very experimental scene interface for specular ray tracing.
Definition SceneInterface.h:35
static constexpr std::size_t cMaxOrder
Definition SceneInterface.h:37
static void AccumulateMaterialAbsorption(const SceneType &scene, std::span< const int > surfaces, EnergyBands &outEnergyLoss)
Definition SceneInterface.h:151
static void ReconstructImageSources(const SceneType &scene, std::span< const int > pathNodes, const OnISsReadyCallback &callback)
Definition SceneInterface.h:163
static std::optional< Vec3 > ReflectPoint(const SceneType &scene, const Vec3 &point, int surfaceId)
Definition SceneInterface.h:72
static bool ValidatePath(const SceneType &scene, std::span< const int > triCache, std::span< const Vec3 > imageSources, const Vec3 &receiver)
Definition SceneInterface.h:82
Definition StaticArray.h:35
constexpr JPL_INLINE reference back() noexcept
Definition StaticArray.h:95
constexpr JPL_INLINE void push_back(const T &value)
Definition StaticArray.h:145
constexpr JPL_INLINE size_type size() const
Definition StaticArray.h:77
Definition AcousticMaterial.h:36
Definition SpecularPath.h:57
std::span< int > Nodes
Definition SpecularPath.h:59
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60