feat: Billboard unattached sketch vertices

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-16 16:48:31 -07:00
parent bc2e84a537
commit aaaf9a44ff

View File

@@ -764,29 +764,25 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
QVector<GLfloat> circleVertices;
const float radius = 0.005f * -m_camera->zoom();
const int numSegments = 16;
auto sketchPlane = sketch->plane();
QMatrix4x4 invModelView = m_camera->modelViewMatrix().inverted();
QVector3D rightVec = invModelView.column(0).toVector3D();
QVector3D upVec = invModelView.column(1).toVector3D();
for (const auto& pair : vertexCounts) {
if (pair.second == 1) {
const gp_Pnt& center = pair.first;
const gp_Pnt& centerPnt = pair.first;
QVector3D center(centerPnt.X(), centerPnt.Y(), centerPnt.Z());
for (int i = 0; i < numSegments; ++i) {
float angle1 = (2.0f * M_PI * float(i)) / float(numSegments);
float angle2 = (2.0f * M_PI * float(i + 1)) / float(numSegments);
float x1, y1, z1, x2, y2, z2;
QVector3D p1 = center + radius * (cos(angle1) * rightVec + sin(angle1) * upVec);
QVector3D p2 = center + radius * (cos(angle2) * rightVec + sin(angle2) * upVec);
if (sketchPlane == SketchFeature::SketchPlane::XY) {
x1 = center.X() + radius * cos(angle1); y1 = center.Y() + radius * sin(angle1); z1 = center.Z();
x2 = center.X() + radius * cos(angle2); y2 = center.Y() + radius * sin(angle2); z2 = center.Z();
} else if (sketchPlane == SketchFeature::SketchPlane::XZ) {
x1 = center.X() + radius * cos(angle1); y1 = center.Y(); z1 = center.Z() + radius * sin(angle1);
x2 = center.X() + radius * cos(angle2); y2 = center.Y(); z2 = center.Z() + radius * sin(angle2);
} else { // YZ
x1 = center.X(); y1 = center.Y() + radius * cos(angle1); z1 = center.Z() + radius * sin(angle1);
x2 = center.X(); y2 = center.Y() + radius * cos(angle2); z2 = center.Z() + radius * sin(angle2);
}
circleVertices << x1 << y1 << z1;
circleVertices << x2 << y2 << z2;
circleVertices << p1.x() << p1.y() << p1.z();
circleVertices << p2.x() << p2.y() << p2.z();
}
}
}