Skip to content
Snippets Groups Projects
Commit 5306d480 authored by Yoel's avatar Yoel
Browse files

Fixed warnings by using proper types for arguments

parent 9e086fdd
No related branches found
No related tags found
No related merge requests found
......@@ -9,15 +9,15 @@ Background::Background(const std::shared_ptr<material::Material>& material)
// TODO TEXELS
std::optional<cam::Hit> Background::intersect(const cam::Ray& r) const {
return std::optional<cam::Hit>({r(std::numeric_limits<float>::infinity()),
util::Vec3(0, 0, 0),
{0, 0},
util::Vec3({}),
{},
std::numeric_limits<float>::infinity(),
material});
}
// Not used
std::pair<float, float> Background::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({0, 0});
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox Background::bounds() const {
......
......@@ -37,7 +37,7 @@ std::optional<cam::Hit> CirclePlane::intersect(const cam::Ray& r) const {
std::pair<float, float> CirclePlane::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>(
{pos.x() / radius + 0.5, pos.z() / radius + 0.5});
{pos.x() / radius + 0.5f, pos.z() / radius + 0.5f});
}
util::AxisAlignedBoundingBox CirclePlane::bounds() const {
......
......@@ -48,7 +48,7 @@ std::optional<cam::Hit> Group::intersect(const cam::Ray& r) const {
// Not used
std::pair<float, float> Group::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({0, 0});
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox Group::bounds() const {
return boundingVolume;
......
......@@ -40,7 +40,7 @@ std::optional<cam::Hit> RectanglePlane::intersect(const cam::Ray& r) const {
std::pair<float, float> RectanglePlane::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>(
{pos.x() / width + 0.5, pos.z() / depth + 0.5});
{pos.x() / width + 0.5f, pos.z() / depth + 0.5f});
}
util::AxisAlignedBoundingBox RectanglePlane::bounds() const {
return util::AxisAlignedBoundingBox(util::Vec3(-width / 2, 0, -depth / 2),
......
......@@ -35,7 +35,7 @@ std::optional<cam::Hit> ShapeSingleGroup::intersect(const cam::Ray& r) const {
}
std::pair<float, float> ShapeSingleGroup::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({0, 0});
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox ShapeSingleGroup::bounds() const {
return boundingVolume;
......
......@@ -49,7 +49,8 @@ std::pair<float, float> Sphere::texture_coordinates(
const util::Vec3& pos) const {
float theta = std::acos(pos.y() / radius);
float phi = M_PI + std::atan2(pos.x(), pos.z());
return std::pair<float, float>({phi / (2 * M_PI), theta / M_PI});
return std::pair<float, float>(
{(float)(phi / (2 * M_PI)), (float)(theta / M_PI)});
}
util::AxisAlignedBoundingBox Sphere::bounds() const {
return util::AxisAlignedBoundingBox(util::Vec3(-radius),
......
......@@ -51,7 +51,7 @@ std::optional<cam::Hit> Triangle::intersect(const cam::Ray& r) const {
// TODO
std::pair<float, float> Triangle::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({0, 0});
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox Triangle::bounds() const {
// std::cout << "In tri bounds" << std::endl;
......
......@@ -31,25 +31,25 @@ std::optional<cam::Hit> TriangleMesh::intersect(size_t i,
const cam::Ray& r) const {
if (!hierarchy[i].bb.intersects(r)) return std::nullopt;
std::array<cam::Hit, 3> hits = {
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(), nullptr),
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(), nullptr),
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(), nullptr)};
// Check left
size_t left_i = hierarchy[i].left;
std::optional<cam::Hit> left_hit = std::nullopt;
if (left_i != -1) left_hit = intersect(left_i, r);
hits[0] = left_hit.value_or(
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
std::numeric_limits<float>::infinity(), nullptr));
hits[0] = left_hit.value_or(cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(),
nullptr));
// Check right
size_t right_i = hierarchy[i].right;
std::optional<cam::Hit> right_hit = std::nullopt;
if (right_i != -1) right_hit = intersect(right_i, r);
hits[1] = right_hit.value_or(
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(), nullptr));
std::optional<cam::Hit> temp = std::nullopt;
......@@ -69,9 +69,9 @@ std::optional<cam::Hit> TriangleMesh::intersect(size_t i,
}
}
}
hits[2] = mid_hit.value_or(
cam::Hit(util::Vec3(0), util::Vec3(0), {0.0, 0.0},
std::numeric_limits<float>::infinity(), nullptr));
hits[2] = mid_hit.value_or(cam::Hit(util::Vec3({}), util::Vec3({}), {},
std::numeric_limits<float>::infinity(),
nullptr));
std::sort(hits.begin(), hits.end(),
[](cam::Hit a, cam::Hit b) { return a.scalar() < b.scalar(); });
if (hits[0].material == nullptr) return std::nullopt;
......@@ -81,14 +81,14 @@ std::optional<cam::Hit> TriangleMesh::intersect(size_t i,
// TODO
std::pair<float, float> TriangleMesh::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({0.0, 0.0});
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox TriangleMesh::bounds() const {
return hierarchy[0].bb;
}
// TODO
util::SurfacePoint TriangleMesh::sampleLight() const {
return util::SurfacePoint(util::Vec3(0), 0, {0.0, 0.0}, material);
return util::SurfacePoint(util::Vec3({}), 0, {}, material);
}
// TODO
util::Vec3 TriangleMesh::calculateLightEmission(const util::SurfacePoint& p,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment