Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leroyvn committed Jun 9, 2021
1 parent 725b7d6 commit c9282a0
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/sensors/distant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,11 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
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<ScalarFloat> * film_sample.x());
v0.x() = c;
v0.z() = s;
std::tie(v0.x(), v0.z()) = enoki::sincos(math::Pi<ScalarFloat> * film_sample.x());
}

// By default, rays point inwards the target direction,
Expand All @@ -341,25 +338,19 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
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<Wavelength>());
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<Float> * sqr(m_bsphere.radius);
Expand All @@ -374,9 +365,7 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
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;
Expand Down

0 comments on commit c9282a0

Please sign in to comment.