Skip to content

Commit 2871201

Browse files
committed
refactoring
1 parent 244cf7c commit 2871201

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/painter/integrators/bpt/connect.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ namespace ns::painter::integrators::bpt
4545
{
4646
namespace
4747
{
48+
template <std::size_t N, typename T, typename Color>
49+
[[nodiscard]] std::optional<Color> connect_s_0_surface(const vertex::Surface<N, T, Color>& surface)
50+
{
51+
if (!surface.is_light())
52+
{
53+
return std::nullopt;
54+
}
55+
if (const auto& radiance = surface.light_radiance())
56+
{
57+
return *radiance * surface.beta();
58+
}
59+
return std::nullopt;
60+
}
61+
4862
template <std::size_t N, typename T, typename Color>
4963
[[nodiscard]] std::optional<Color> connect_s_0_infinite_light(
5064
const Scene<N, T, Color>& scene,
@@ -73,15 +87,7 @@ template <std::size_t N, typename T, typename Color>
7387
const Visitors visitors{
7488
[](const vertex::Surface<N, T, Color>& surface) -> std::optional<Color>
7589
{
76-
if (!surface.is_light())
77-
{
78-
return std::nullopt;
79-
}
80-
if (const auto& radiance = surface.light_radiance())
81-
{
82-
return *radiance * surface.beta();
83-
}
84-
return std::nullopt;
90+
return connect_s_0_surface(surface);
8591
},
8692
[](const vertex::Camera<N, T, Color>&) -> std::optional<Color>
8793
{

0 commit comments

Comments
 (0)