diff --git a/src/sensors/distant.cpp b/src/sensors/distant.cpp index c618c1a90..cf4c0a5e9 100644 --- a/src/sensors/distant.cpp +++ b/src/sensors/distant.cpp @@ -317,14 +317,11 @@ class DistantSensorImpl final : public Sensor { auto trafo = m_world_transform->eval(time, active); Vector3f v0{ 0.f, 0.f, 1.f }; - if (m_direction_type == RayDirectionType::SampleAll) + if (m_direction_type == RayDirectionType::SampleAll) { v0 = warp::square_to_uniform_hemisphere(film_sample); - - else if (m_direction_type == RayDirectionType::SampleWidth) { + } else if (m_direction_type == RayDirectionType::SampleWidth) { // Sample directions only in plane generated by X and Z axes - auto [s, c] = sincos(math::Pi * film_sample.x()); - v0.x() = c; - v0.z() = s; + std::tie(v0.x(), v0.z()) = enoki::sincos(math::Pi * film_sample.x()); } // By default, rays point inwards the target direction, @@ -341,25 +338,19 @@ class DistantSensorImpl final : public Sensor { if constexpr (TargetType == RayTargetType::Point) { // Target point selection already handled during init ray_weight = wav_weight; - } - - else if constexpr (TargetType == RayTargetType::Shape) { + } else if constexpr (TargetType == RayTargetType::Shape) { // Use area-based sampling of shape PositionSample3f ps = m_ray_target_shape->sample_position( time, aperture_sample, active); - SurfaceInteraction3f si(ps, zero()); - ray_target = si.p; - ray_weight = - wav_weight / ps.pdf / m_ray_target_shape->surface_area(); + ray_target = ps.p; + ray_weight = wav_weight / ps.pdf / m_ray_target_shape->surface_area(); /* ray_weight *= dot(-ray.d, si.n); */ - } - - else { // if constexpr (TargetType == RayTargetType::None) { + } else { // if constexpr (TargetType == RayTargetType::None) { // Sample target uniformly on bounding sphere cross section Point2f offset = warp::square_to_uniform_disk_concentric(aperture_sample); Vector3f perp_offset = - trafo.transform_affine(Vector3f{ offset.x(), offset.y(), 0.f }); + trafo.transform_affine(Vector3f(offset.x(), offset.y(), 0.f)); ray_target = m_bsphere.center + perp_offset * m_bsphere.radius; ray_weight = wav_weight; // ray_weight *= math::Pi * sqr(m_bsphere.radius); @@ -374,9 +365,7 @@ class DistantSensorImpl final : public Sensor { tmp_ray, HitComputeFlags::Minimal, active); active &= si.is_valid(); ray.o = si.p; - } - - else { // if constexpr (OriginType == OriginType::BoundingSphere) { + } else { // if constexpr (OriginType == OriginType::BoundingSphere) { // Use the scene's bounding sphere to safely position ray origin if constexpr (TargetType == RayTargetType::None) ray.o = ray_target - ray.d * m_bsphere.radius;