diff options
Diffstat (limited to 'src/obj_parser.cpp')
-rw-r--r-- | src/obj_parser.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/obj_parser.cpp b/src/obj_parser.cpp index ad71935..f765f5c 100644 --- a/src/obj_parser.cpp +++ b/src/obj_parser.cpp @@ -34,7 +34,7 @@ float parse_float(const std::string& s) { if (s[ind++] == '-') positive = !positive; - // improve error checking + // TODO: improve error checking if (ind == s.length()) return 0.f; @@ -45,7 +45,7 @@ float parse_float(const std::string& s) { if (ind == s.length()) return (positive ? 1.f : -1.f) * static_cast<float>(n); - // improve error checking + // TODO: improve error checking if (s[ind] != '.') return 0.f; @@ -58,7 +58,7 @@ float parse_float(const std::string& s) { decimal_fac *= .1f; } - // improve error checking + // TODO: improve error checking if (ind != s.length()) return 0.f; @@ -72,7 +72,7 @@ float parse_int(const std::string& s) { if (s[ind++] == '-') positive = !positive; - // improve error checking + // TODO: improve error checking if (ind == s.length()) return 0.f; @@ -80,7 +80,7 @@ float parse_int(const std::string& s) { while (ind < s.length() && s[ind] >= '0' && s[ind] <= '9') n = n * 10 + static_cast<int>(s[ind++]) - static_cast<int>('0'); - // improve error checking + // TODO: improve error checking if (ind != s.length()) return 0.f; @@ -91,7 +91,6 @@ float parse_int(const std::string& s) { o3d::Mesh parse_object(const std::string& obj_path) { o3d::Mesh mesh; - mesh.vertices_data.push_back(o3d::VertexData(0.f, 0.f)); std::ifstream obj_file(obj_path); std::string line; while (std::getline(obj_file, line)) { @@ -119,13 +118,12 @@ o3d::Mesh parse_object(const std::string& obj_path) { // } // std::cout << "Smooth: " << std::boolalpha << smooth << std::endl; } else if (line.rfind("f ", 0) == 0) { - std::array<std::array<std::size_t, 3>, 3> indices; + std::array<std::array<std::size_t, 2>, 3> indices; auto line_split = split(line.substr(2), ' '); for (int i = 0; i < 3; i++) { auto indices_s_group = split(line_split[i], '/'); indices[i][0] = parse_int(indices_s_group[0]) - 1; indices[i][1] = parse_int(indices_s_group[2]) - 1; - indices[i][2] = 0; } // std::cout << "Face:" // << " 1: vertex: " << indices[0][0] << " normal: " << indices[0][1] |