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 a51041d commit 725b7d6
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/sensors/distant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class DistantSensorImpl;
.. _sensor-distant:
Distant directional sensor (:monosp:`distant`)
----------------------------------------------
Distant radiancemeter sensor (:monosp:`distant`)
------------------------------------------------
.. pluginparameters::
Expand Down Expand Up @@ -111,13 +111,14 @@ class DistantSensor final : public Sensor<Float, Spectrum> {

// Get target
if (props.has_property("ray_target")) {
try {
// We first try to get a point
if (props.type("ray_target") == Properties::Type::Array3f) {
props.point3f("ray_target");
m_ray_target_type = RayTargetType::Point;
} catch (const std::runtime_error &e) {
// If it fails, we assume it's a shape
} else if (props.type("ray_target") == Properties::Type::Object) {
// We assume it's a shape
m_ray_target_type = RayTargetType::Shape;
} else {
Throw("Unsupported 'ray_target' parameter type");
}
} else {
m_ray_target_type = RayTargetType::None;
Expand All @@ -126,9 +127,8 @@ class DistantSensor final : public Sensor<Float, Spectrum> {
// Get origin
if (props.has_property("ray_origin"))
m_ray_origin_type = RayOriginType::Shape;
else {
else
m_ray_origin_type = RayOriginType::BoundingSphere;
}

props.mark_queried("direction");
props.mark_queried("flip_directions");
Expand Down Expand Up @@ -229,19 +229,21 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
// Check film size and select direction sampling mode
auto film_size = m_film->size();

if (film_size == ScalarPoint2i(1, 1))
if (film_size == ScalarPoint2i(1, 1)) {
m_direction_type = RayDirectionType::Single;
else if (film_size[1] == 1) {
} else if (film_size[1] == 1) {
Log(Info, "Directions in plane");
m_direction_type = RayDirectionType::SampleWidth;
} else
} else {
m_direction_type = RayDirectionType::SampleAll;
}

// Check reconstruction filter radius
if (m_film->reconstruction_filter()->radius() >
0.5f + math::RayEpsilon<Float>)
0.5f + math::RayEpsilon<Float>) {
Log(Warn, "This sensor should be used with a reconstruction filter "
"with a radius of 0.5 or lower (e.g. default box)");
}

// Compute transform, possibly based on direction parameter
if (props.has_property("direction")) {
Expand Down Expand Up @@ -279,7 +281,7 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {

// Set ray origin
if constexpr (OriginType == RayOriginType::Shape) {
auto obj = props.object("ray_origin");
auto obj = props.object("ray_origin");
m_ray_origin_shape = dynamic_cast<Shape *>(obj.get());

if (!m_ray_origin_shape)
Expand Down Expand Up @@ -382,7 +384,7 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
ray.o = ray_target - ray.d * 2.f * m_bsphere.radius;
}

return { ray, ray_weight && active };
return { ray, ray_weight & active };
}

std::pair<Ray3f, Spectrum> sample_ray(Float time, Float wavelength_sample,
Expand All @@ -394,7 +396,7 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
auto [ray, ray_weight] = sample_ray_impl<Ray3f>(
time, wavelength_sample, film_sample, aperture_sample, active);
ray.update();
return { ray, ray_weight && active };
return { ray, ray_weight & active };
}

std::pair<RayDifferential3f, Spectrum> sample_ray_differential(
Expand All @@ -409,7 +411,7 @@ class DistantSensorImpl final : public Sensor<Float, Spectrum> {
ray.has_differentials = false;

ray.update();
return { ray, ray_weight && active };
return { ray, ray_weight & active };
}

// This sensor does not occupy any particular region of space, return an
Expand Down

0 comments on commit 725b7d6

Please sign in to comment.