src/geometry.cpp

changeset 250
2837b549e616
parent 223
ce81db996275
child 264
76a025db4948
equal deleted inserted replaced
249:37d3c819cafa 250:2837b549e616
215 }); 215 });
216 } 216 }
217 217
218 bool isConvex(const std::vector<glm::vec3>& polygon) 218 bool isConvex(const std::vector<glm::vec3>& polygon)
219 { 219 {
220 const int n = polygon.size(); 220 const std::size_t n = polygon.size();
221 auto polygonRing = iter::ring(polygon, n); 221 auto polygonRing = iter::ring(polygon, n);
222 std::vector<glm::vec3> crosses; 222 std::vector<glm::vec3> crosses;
223 crosses.resize(n); 223 crosses.resize(n);
224 for (int i = 0; i < n; i += 1) 224 for (std::size_t i = 0; i < n; i += 1)
225 { 225 {
226 crosses[i] = glm::cross(polygonRing[i - 1] - polygonRing[i], polygonRing[i + 1] - polygonRing[i]); 226 crosses[i] = glm::cross(polygonRing[i - 1] - polygonRing[i], polygonRing[i + 1] - polygonRing[i]);
227 } 227 }
228 return not std::any_of( 228 return not std::any_of(
229 crosses.begin() + 1, 229 crosses.begin() + 1,

mercurial