From 7b78ff1f06d124db52697955c06b218cb6c2f905 Mon Sep 17 00:00:00 2001 From: Yoel <s73017@beuth-hochschule.de> Date: Thu, 10 Sep 2020 22:13:14 +0200 Subject: [PATCH] Streamlined optional returns --- RayTracer/shape/Sphere.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RayTracer/shape/Sphere.cpp b/RayTracer/shape/Sphere.cpp index e081cc3..1c09f2f 100644 --- a/RayTracer/shape/Sphere.cpp +++ b/RayTracer/shape/Sphere.cpp @@ -25,7 +25,7 @@ std::optional<cam::Hit> Sphere::intersect(const cam::Ray& r) const { float theta = acos(t1HitPoint.y() / radius); float phi = M_PI + atan2(t1HitPoint.x(), t1HitPoint.z()); return std::optional<cam::Hit>( - cam::Hit(t1HitPoint, t1HitPoint, t1, material)); + {t1HitPoint, t1HitPoint, t1, material}); } else { float t2 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a); if (r.in_range(t2)) { @@ -33,7 +33,7 @@ std::optional<cam::Hit> Sphere::intersect(const cam::Ray& r) const { float theta = acos(t2HitPoint.y() / radius); float phi = M_PI + atan2(t2HitPoint.x(), t2HitPoint.z()); return std::optional<cam::Hit>( - cam::Hit(t2HitPoint, t2HitPoint, t2, material)); + {t2HitPoint, t2HitPoint, t2, material}); } else { return std::nullopt; } -- GitLab