~ | removing useless trycatch

This commit is contained in:
RedShip
2025-01-13 18:50:55 +01:00
parent 449f059a07
commit 819c07f90d
8 changed files with 136 additions and 191 deletions

View File

@ -20,7 +20,6 @@ class Cube : public Object
public:
Cube(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float width, height, depth;
int mat_index;
@ -39,8 +38,6 @@ class Cube : public Object
_mat_index = mat_index;
}
catch (const std::exception& e) { throw; }
}
Cube(const glm::vec3& position, const glm::vec3 &size, const int mat_index)
: Object(position, mat_index), _size(size) {}

View File

@ -20,7 +20,6 @@ class Cylinder : public Object
public:
Cylinder(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float radius, height;
float pitch, yaw, roll;
@ -48,8 +47,6 @@ class Cylinder : public Object
_mat_index = mat_index;
}
catch (const std::exception& e) { throw; }
}
Cylinder(const glm::vec3& position, float radius, const int mat_index)
: Object(position, mat_index), _radius(radius) {}

View File

@ -20,7 +20,6 @@ class Plane : public Object
public:
Plane(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float nx, ny, nz;
int mat_index;
@ -39,8 +38,6 @@ class Plane : public Object
_mat_index = mat_index;
}
catch (const std::exception &e) { throw; }
}
Plane(const glm::vec3 &position, const glm::vec3 &normal, const int mat_index)
: Object(position, mat_index), _normal(normal) {}

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2024/12/23 19:47:09 by ycontre ### ########.fr */
/* Updated: 2025/01/13 18:44:40 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,6 @@ class Portal : public Object
public:
Portal(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float x1, y1, z1;
float x2, y2, z2;
@ -61,8 +60,6 @@ class Portal : public Object
_mat_index = mat_index;
}
catch (const std::exception &e) { throw; }
}
Portal(const glm::vec3 &position, const glm::vec3 &edge1, const glm::vec3 &edge2, const int linked_portal, const int mat_index)
: Object(position, mat_index), _up(edge1), _right(edge2), _linked_portal(linked_portal) {}

View File

@ -20,7 +20,6 @@ class Quad : public Object
public:
Quad(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float x1, y1, z1;
float x2, y2, z2;
@ -44,8 +43,6 @@ class Quad : public Object
_mat_index = mat_index;
}
catch (const std::exception &e) { throw; }
}
Quad(const glm::vec3 &position, const glm::vec3 &edge1, const glm::vec3 &edge2, const int mat_index)
: Object(position, mat_index), _up(edge1), _right(edge2) {}

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2025/01/08 20:20:34 by ycontre ### ########.fr */
/* Updated: 2025/01/13 18:46:58 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,6 @@ class Sphere : public Object
public:
Sphere(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z, radius;
int mat_index;
@ -38,8 +37,6 @@ class Sphere : public Object
_mat_index = mat_index;
}
catch (const std::exception& e) { throw; }
}
Sphere(const glm::vec3& position, float radius, const int mat_index)
: Object(position, mat_index), _radius(radius) {}

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2025/01/13 17:59:21 by tomoron ### ########.fr */
/* Updated: 2025/01/13 18:43:18 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,6 @@ class Triangle : public Object
public:
Triangle(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float x2, y2, z2;
float x3, y3, z3;
@ -50,8 +49,6 @@ class Triangle : public Object
_mat_index = mat_index;
}
catch (const std::exception &e) { throw; }
}
Triangle(const glm::vec3& position, const glm::vec3& vertex2, const glm::vec3& vertex3, const int mat_index)
: Object(position, mat_index), _vertex2(vertex2), _vertex3(vertex3) {
_vertex2 -= _position; //optimization

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* SceneParser.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/26 21:43:51 by TheRed #+# #+# */
/* Updated: 2025/01/13 17:59:30 by tomoron ### ########.fr */
/* Updated: 2025/01/13 18:49:10 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,47 +14,13 @@
SceneParser::SceneParser(Scene *scene) : _scene(scene)
{
object_parsers["sp"] = [](std::stringstream &ss) -> Object *
{
try { return (new Sphere(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["pl"] = [](std::stringstream &ss) -> Object *
{
try { return (new Plane(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["qu"] = [](std::stringstream &ss) -> Object *
{
try { return (new Quad(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["tr"] = [](std::stringstream &ss) -> Object *
{
try { return (new Triangle(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["cu"] = [](std::stringstream &ss) -> Object *
{
try { return (new Cube(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["po"] = [](std::stringstream &ss) -> Object *
{
try { return (new Portal(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["cy"] = [](std::stringstream &ss) -> Object *
{
try { return (new Cylinder(ss)); }
catch (const std::exception &e) { throw; }
};
object_parsers["sp"] = [](std::stringstream &ss) -> Object * { return (new Sphere(ss)); };
object_parsers["pl"] = [](std::stringstream &ss) -> Object * { return (new Plane(ss)); };
object_parsers["qu"] = [](std::stringstream &ss) -> Object * { return (new Quad(ss)); };
object_parsers["tr"] = [](std::stringstream &ss) -> Object * { return (new Triangle(ss)); };
object_parsers["cu"] = [](std::stringstream &ss) -> Object * { return (new Cube(ss)); };
object_parsers["po"] = [](std::stringstream &ss) -> Object * { return (new Portal(ss)); };
object_parsers["cy"] = [](std::stringstream &ss) -> Object * { return (new Cylinder(ss)); };
}
void SceneParser::parseMaterial(std::stringstream &line)