diff --git a/src/Snapping.cpp b/src/Snapping.cpp index c1f1af2..dc17f22 100644 --- a/src/Snapping.cpp +++ b/src/Snapping.cpp @@ -29,10 +29,10 @@ bool Snapping::update(const QPoint& mousePos) switch (m_viewport->currentPlane()) { case ViewportWidget::SketchPlane::XY: - shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.z()) < snapRectHalfSize; + shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.y()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::XZ: - shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.y()) < snapRectHalfSize; + shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.z()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::YZ: shouldSnap = qAbs(worldPos.y()) < snapRectHalfSize && qAbs(worldPos.z()) < snapRectHalfSize; @@ -62,10 +62,10 @@ bool Snapping::update(const QPoint& mousePos) bool isClose = false; switch (m_viewport->currentPlane()) { case ViewportWidget::SketchPlane::XY: - isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; + isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::XZ: - isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize; + isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::YZ: isClose = qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; @@ -88,10 +88,10 @@ bool Snapping::update(const QPoint& mousePos) if (sketch->plane() == SketchFeature::SketchPlane::XY) { p2.SetCoord(p3.X(), p1.Y(), p1.Z()); - p4.SetCoord(p1.X(), p1.Y(), p3.Z()); + p4.SetCoord(p1.X(), p3.Y(), p1.Z()); } else if (sketch->plane() == SketchFeature::SketchPlane::XZ) { p2.SetCoord(p3.X(), p1.Y(), p1.Z()); - p4.SetCoord(p1.X(), p3.Y(), p1.Z()); + p4.SetCoord(p1.X(), p1.Y(), p3.Z()); } else if (sketch->plane() == SketchFeature::SketchPlane::YZ) { p2.SetCoord(p1.X(), p3.Y(), p1.Z()); p4.SetCoord(p1.X(), p1.Y(), p3.Z()); @@ -102,10 +102,10 @@ bool Snapping::update(const QPoint& mousePos) bool isClose = false; switch (m_viewport->currentPlane()) { case ViewportWidget::SketchPlane::XY: - isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; + isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::XZ: - isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize; + isClose = qAbs(worldPos.x() - vertex.X()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; break; case ViewportWidget::SketchPlane::YZ: isClose = qAbs(worldPos.y() - vertex.Y()) < snapRectHalfSize && qAbs(worldPos.z() - vertex.Z()) < snapRectHalfSize; @@ -140,15 +140,15 @@ void Snapping::paintGL() const if (m_isSnappingOrigin) { const float rectSize = 0.0075f * -m_viewport->camera()->zoom(); if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XY) { - vertices << -rectSize << 0 << -rectSize << rectSize << 0 << -rectSize; - vertices << rectSize << 0 << -rectSize << rectSize << 0 << rectSize; - vertices << rectSize << 0 << rectSize << -rectSize << 0 << rectSize; - vertices << -rectSize << 0 << rectSize << -rectSize << 0 << -rectSize; - } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XZ) { vertices << -rectSize << -rectSize << 0 << rectSize << -rectSize << 0; vertices << rectSize << -rectSize << 0 << rectSize << rectSize << 0; vertices << rectSize << rectSize << 0 << -rectSize << rectSize << 0; vertices << -rectSize << rectSize << 0 << -rectSize << -rectSize << 0; + } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XZ) { + vertices << -rectSize << 0 << -rectSize << rectSize << 0 << -rectSize; + vertices << rectSize << 0 << -rectSize << rectSize << 0 << rectSize; + vertices << rectSize << 0 << rectSize << -rectSize << 0 << rectSize; + vertices << -rectSize << 0 << rectSize << -rectSize << 0 << -rectSize; } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::YZ) { vertices << 0 << -rectSize << -rectSize << 0 << rectSize << -rectSize; vertices << 0 << rectSize << -rectSize << 0 << rectSize << rectSize; @@ -159,15 +159,15 @@ void Snapping::paintGL() const const float rectSize = 0.0075f * -m_viewport->camera()->zoom(); const auto& v = m_snapVertex; if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XY) { - vertices << v.X() - rectSize << v.Y() << v.Z() - rectSize << v.X() + rectSize << v.Y() << v.Z() - rectSize; - vertices << v.X() + rectSize << v.Y() << v.Z() - rectSize << v.X() + rectSize << v.Y() << v.Z() + rectSize; - vertices << v.X() + rectSize << v.Y() << v.Z() + rectSize << v.X() - rectSize << v.Y() << v.Z() + rectSize; - vertices << v.X() - rectSize << v.Y() << v.Z() + rectSize << v.X() - rectSize << v.Y() << v.Z() - rectSize; - } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XZ) { vertices << v.X() - rectSize << v.Y() - rectSize << v.Z() << v.X() + rectSize << v.Y() - rectSize << v.Z(); vertices << v.X() + rectSize << v.Y() - rectSize << v.Z() << v.X() + rectSize << v.Y() + rectSize << v.Z(); vertices << v.X() + rectSize << v.Y() + rectSize << v.Z() << v.X() - rectSize << v.Y() + rectSize << v.Z(); vertices << v.X() - rectSize << v.Y() + rectSize << v.Z() << v.X() - rectSize << v.Y() - rectSize << v.Z(); + } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::XZ) { + vertices << v.X() - rectSize << v.Y() << v.Z() - rectSize << v.X() + rectSize << v.Y() << v.Z() - rectSize; + vertices << v.X() + rectSize << v.Y() << v.Z() - rectSize << v.X() + rectSize << v.Y() << v.Z() + rectSize; + vertices << v.X() + rectSize << v.Y() << v.Z() + rectSize << v.X() - rectSize << v.Y() << v.Z() + rectSize; + vertices << v.X() - rectSize << v.Y() << v.Z() + rectSize << v.X() - rectSize << v.Y() << v.Z() - rectSize; } else if (m_viewport->currentPlane() == ViewportWidget::SketchPlane::YZ) { vertices << v.X() << v.Y() - rectSize << v.Z() - rectSize << v.X() << v.Y() + rectSize << v.Z() - rectSize; vertices << v.X() << v.Y() + rectSize << v.Z() - rectSize << v.X() << v.Y() + rectSize << v.Z() + rectSize;