238 void Canvas::drawWorldPolygon(QPainter* painter, const std::vector<glm::vec3> &points) |
238 void Canvas::drawWorldPolygon(QPainter* painter, const std::vector<glm::vec3> &points) |
239 { |
239 { |
240 painter->drawPolygon(QPolygonF{this->convertWorldPointsToScreenPoints(points)}); |
240 painter->drawPolygon(QPolygonF{this->convertWorldPointsToScreenPoints(points)}); |
241 } |
241 } |
242 |
242 |
|
243 Winding Canvas::worldPolygonWinding(const std::vector<glm::vec3> &points) const |
|
244 { |
|
245 return geom::winding(QPolygonF{this->convertWorldPointsToScreenPoints(points)}); |
|
246 } |
|
247 |
243 /** |
248 /** |
244 * @brief Gets the current position of the cursor in the model |
249 * @brief Gets the current position of the cursor in the model |
245 * @return 3D vector |
250 * @return 3D vector |
246 */ |
251 */ |
247 const std::optional<glm::vec3>& Canvas::getWorldPosition() const |
252 const std::optional<glm::vec3>& Canvas::getWorldPosition() const |
324 // and the grid is perpendicular to the screen. |
329 // and the grid is perpendicular to the screen. |
325 const float dot = glm::dot(glm::normalize(this->gridPlane.normal), glm::normalize(cameraDirection)); |
330 const float dot = glm::dot(glm::normalize(this->gridPlane.normal), glm::normalize(cameraDirection)); |
326 return std::abs(dot) < threshold; |
331 return std::abs(dot) < threshold; |
327 } |
332 } |
328 |
333 |
329 QVector<QPointF> Canvas::convertWorldPointsToScreenPoints(const std::vector<glm::vec3> &worldPoints) |
334 QVector<QPointF> Canvas::convertWorldPointsToScreenPoints(const std::vector<glm::vec3> &worldPoints) const |
330 { |
335 { |
331 QVector<QPointF> points2d; |
336 QVector<QPointF> points2d; |
332 points2d.reserve(worldPoints.size()); |
337 points2d.reserve(worldPoints.size()); |
333 for (const glm::vec3& point : worldPoints) |
338 for (const glm::vec3& point : worldPoints) |
334 { |
339 { |