Skip to content

Commit 725b7d6

Browse files
committed
Style fixes
1 parent a51041d commit 725b7d6

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/sensors/distant.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class DistantSensorImpl;
2323
2424
.. _sensor-distant:
2525
26-
Distant directional sensor (:monosp:`distant`)
27-
----------------------------------------------
26+
Distant radiancemeter sensor (:monosp:`distant`)
27+
------------------------------------------------
2828
2929
.. pluginparameters::
3030
@@ -111,13 +111,14 @@ class DistantSensor final : public Sensor<Float, Spectrum> {
111111

112112
// Get target
113113
if (props.has_property("ray_target")) {
114-
try {
115-
// We first try to get a point
114+
if (props.type("ray_target") == Properties::Type::Array3f) {
116115
props.point3f("ray_target");
117116
m_ray_target_type = RayTargetType::Point;
118-
} catch (const std::runtime_error &e) {
119-
// If it fails, we assume it's a shape
117+
} else if (props.type("ray_target") == Properties::Type::Object) {
118+
// We assume it's a shape
120119
m_ray_target_type = RayTargetType::Shape;
120+
} else {
121+
Throw("Unsupported 'ray_target' parameter type");
121122
}
122123
} else {
123124
m_ray_target_type = RayTargetType::None;
@@ -126,9 +127,8 @@ class DistantSensor final : public Sensor<Float, Spectrum> {
126127
// Get origin
127128
if (props.has_property("ray_origin"))
128129
m_ray_origin_type = RayOriginType::Shape;
129-
else {
130+
else
130131
m_ray_origin_type = RayOriginType::BoundingSphere;
131-
}
132132

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

232-
if (film_size == ScalarPoint2i(1, 1))
232+
if (film_size == ScalarPoint2i(1, 1)) {
233233
m_direction_type = RayDirectionType::Single;
234-
else if (film_size[1] == 1) {
234+
} else if (film_size[1] == 1) {
235235
Log(Info, "Directions in plane");
236236
m_direction_type = RayDirectionType::SampleWidth;
237-
} else
237+
} else {
238238
m_direction_type = RayDirectionType::SampleAll;
239+
}
239240

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

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

280282
// Set ray origin
281283
if constexpr (OriginType == RayOriginType::Shape) {
282-
auto obj = props.object("ray_origin");
284+
auto obj = props.object("ray_origin");
283285
m_ray_origin_shape = dynamic_cast<Shape *>(obj.get());
284286

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

385-
return { ray, ray_weight && active };
387+
return { ray, ray_weight & active };
386388
}
387389

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

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

411413
ray.update();
412-
return { ray, ray_weight && active };
414+
return { ray, ray_weight & active };
413415
}
414416

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

0 commit comments

Comments
 (0)