feat: Make snap origin indicator 50% transparent and region rectangular

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-14 22:12:36 -07:00
parent 886a8a72d6
commit 78ac60926d

View File

@@ -139,7 +139,9 @@ void ViewportWidget::paintGL()
if (m_isSnappingOrigin) { if (m_isSnappingOrigin) {
const float rectSize = 0.0075f * -m_zoom; const float rectSize = 0.0075f * -m_zoom;
glColor3f(1.0, 1.0, 0.0); glColor4f(1.0, 1.0, 0.0, 0.5f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
if (m_currentPlane == SketchPlane::XY) { if (m_currentPlane == SketchPlane::XY) {
glVertex3f(-rectSize, -rectSize, 0); glVertex3f(-rectSize, -rectSize, 0);
@@ -158,6 +160,7 @@ void ViewportWidget::paintGL()
glVertex3f(0, -rectSize, rectSize); glVertex3f(0, -rectSize, rectSize);
} }
glEnd(); glEnd();
glDisable(GL_BLEND);
} }
if (m_isDefiningLine && m_activeTool == static_cast<int>(ApplicationController::ToolType::Line)) { if (m_isDefiningLine && m_activeTool == static_cast<int>(ApplicationController::ToolType::Line)) {
@@ -231,8 +234,21 @@ void ViewportWidget::mouseMoveEvent(QMouseEvent *event)
bool shouldSnap = false; bool shouldSnap = false;
if (m_currentPlane != SketchPlane::NONE) { if (m_currentPlane != SketchPlane::NONE) {
QVector3D worldPos = unproject(m_currentMousePos); QVector3D worldPos = unproject(m_currentMousePos);
const float snapThreshold = 0.025f * -m_zoom; const float snapRectHalfSize = 0.0075f * -m_zoom;
shouldSnap = worldPos.length() < snapThreshold;
switch (m_currentPlane) {
case SketchPlane::XY:
shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.y()) < snapRectHalfSize;
break;
case SketchPlane::XZ:
shouldSnap = qAbs(worldPos.x()) < snapRectHalfSize && qAbs(worldPos.z()) < snapRectHalfSize;
break;
case SketchPlane::YZ:
shouldSnap = qAbs(worldPos.y()) < snapRectHalfSize && qAbs(worldPos.z()) < snapRectHalfSize;
break;
case SketchPlane::NONE:
break;
}
} }
if (shouldSnap != m_isSnappingOrigin) { if (shouldSnap != m_isSnappingOrigin) {