Skip to content

Commit

Permalink
Fix small compilation warnings (Clang 19)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinND committed Oct 31, 2024
1 parent a3736c8 commit 8bdbb29
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
17 changes: 9 additions & 8 deletions include/mitsuba/core/ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ NAMESPACE_BEGIN(mitsuba)
template <typename Point_, typename Spectrum_> struct Ray {
static constexpr size_t Size = dr::size_v<Point_>;

using Point = Point_;
using Point = Point_;
// TODO: need this because dr::value_t<MaskedArray<Point3f>> isn't a masked array
using Float =
std::conditional_t<dr::is_masked_array_v<Point>,
dr::detail::MaskedArray<dr::value_t<Point>>,
dr::value_t<Point>>;
using Vector = mitsuba::Vector<Float, Size>;
using Spectrum = Spectrum_;
using Wavelength = wavelength_t<Spectrum_>;
using ScalarFloat = dr::scalar_t<Float>;
using Vector = mitsuba::Vector<Float, Size>;
using Spectrum = Spectrum_;
using Wavelength = wavelength_t<Spectrum_>;

/// Ray origin
Point o;
Expand All @@ -34,7 +35,7 @@ template <typename Point_, typename Spectrum_> struct Ray {
/// Maximum position on the ray segment
Float maxt = dr::Largest<Float>;
/// Time value associated with this ray
Float time = 0.f;
Float time = (ScalarFloat) 0.f;
/// Wavelength associated with the ray
Wavelength wavelengths;

Expand All @@ -44,7 +45,7 @@ template <typename Point_, typename Spectrum_> struct Ray {
: o(o), d(d), time(time), wavelengths(wavelengths) { }

/// Construct a new ray (o, d) with time
Ray(const Point &o, const Vector &d, const Float &time=0.f)
Ray(const Point &o, const Vector &d, const Float &time = (ScalarFloat) 0.f)
: o(o), d(d), time(time) { }

/// Construct a new ray (o, d) with bounds
Expand Down Expand Up @@ -82,7 +83,7 @@ template <typename Point_, typename Spectrum_>
struct RayDifferential : Ray<Point_, Spectrum_> {
using Base = Ray<Point_, Spectrum_>;

MI_USING_TYPES(Float, Point, Vector, Wavelength)
MI_USING_TYPES(Float, ScalarFloat, Point, Vector, Wavelength)
MI_USING_MEMBERS(o, d, maxt, time, wavelengths)

Point o_x, o_y;
Expand All @@ -94,7 +95,7 @@ struct RayDifferential : Ray<Point_, Spectrum_> {
: Base(ray), o_x(0), o_y(0), d_x(0), d_y(0), has_differentials(false) {}

/// Construct a new ray (o, d) at time 'time'
RayDifferential(const Point &o_, const Vector &d_, Float time_ = 0.f,
RayDifferential(const Point &o_, const Vector &d_, Float time_ = (ScalarFloat) 0.f,
const Wavelength &wavelengths_ = Wavelength())
: o_x(0), o_y(0), d_x(0), d_y(0), has_differentials(false) {
o = o_;
Expand Down
23 changes: 14 additions & 9 deletions src/core/python/ray_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@
template<typename Ray>
void bind_ray(nb::module_ &m, const char *name) {
MI_PY_IMPORT_TYPES()
using Vector = typename Ray::Vector;
using Point = typename Ray::Point;
// Re-import this specific `Ray`'s types in cased of mixed precision
// between Float and Spectrum.
using RayFloat = typename Ray::Float;
using RayScalarFloat = typename Ray::ScalarFloat;
using Vector = typename Ray::Vector;
using Point = typename Ray::Point;
using Wavelength = typename Ray::Wavelength;

MI_PY_CHECK_ALIAS(Ray, name) {
auto ray = nb::class_<Ray>(m, name, D(Ray))
.def(nb::init<>(), "Create an uninitialized ray")
.def(nb::init<const Ray &>(), "Copy constructor", "other"_a)
.def(nb::init<Point, Vector, Float, const Wavelength &>(),
.def(nb::init<Point, Vector, RayFloat, const Wavelength &>(),
D(Ray, Ray, 2),
"o"_a, "d"_a, "time"_a=0.0, "wavelengths"_a=Wavelength())
.def(nb::init<Point, Vector, Float, Float, const Wavelength &>(),
"o"_a, "d"_a, "time"_a=(RayScalarFloat) 0.0, "wavelengths"_a=Wavelength())
.def(nb::init<Point, Vector, RayFloat, RayFloat, const Wavelength &>(),
D(Ray, Ray, 3),
"o"_a, "d"_a, "maxt"_a, "time"_a, "wavelengths"_a)
.def(nb::init<const Ray &, Float>(),
D(Ray, Ray, 4), "other"_a, "maxt"_a)
"o"_a, "d"_a, "maxt"_a, "time"_a, "wavelengths"_a)
.def(nb::init<const Ray &, RayFloat>(),
D(Ray, Ray, 4), "other"_a, "maxt"_a)
.def("__call__", &Ray::operator(), D(Ray, operator, call), "t"_a)
.def_field(Ray, o, D(Ray, o))
.def_field(Ray, d, D(Ray, d))
Expand All @@ -45,7 +50,7 @@ MI_PY_EXPORT(Ray) {
.def(nb::init<const Ray3f &>(), "ray"_a)
.def(nb::init<Point3f, Vector3f, Float, const Wavelength &>(),
"Initialize without differentials.",
"o"_a, "d"_a, "time"_a=0.0, "wavelengths"_a=Wavelength())
"o"_a, "d"_a, "time"_a=(ScalarFloat) 0.0, "wavelengths"_a=Wavelength())
.def("scale_differential", &RayDifferential3f::scale_differential,
"amount"_a, D(RayDifferential, scale_differential))
.def_field(RayDifferential3f, o_x, D(RayDifferential, o_x))
Expand Down

0 comments on commit 8bdbb29

Please sign in to comment.