--- a/src/geometry.cpp Tue Jun 28 19:31:55 2022 +0300 +++ b/src/geometry.cpp Tue Jun 28 19:35:09 2022 +0300 @@ -1,7 +1,6 @@ #include <glm/gtc/matrix_transform.hpp> #include "src/geometry.h" #include "src/basics.h" -#include "src/ring.h" /** * @brief Computes line-plane intersection @@ -218,12 +217,14 @@ bool isConvex(const std::vector<glm::vec3>& polygon) { const std::size_t n = polygon.size(); - auto polygonRing = iter::ring(polygon, n); std::vector<glm::vec3> crosses; crosses.resize(n); for (std::size_t i = 0; i < n; i += 1) { - crosses[i] = glm::cross(polygonRing[i - 1] - polygonRing[i], polygonRing[i + 1] - polygonRing[i]); + const glm::vec3 v1 = polygon[(i + n - 1) % n]; + const glm::vec3 v2 = polygon[i]; + const glm::vec3 v3 = polygon[(i + 1) % n]; + crosses[i] = glm::cross(v1 - v2, v3 - v2); } return not std::any_of( crosses.begin() + 1,