feat: Billboard unattached sketch vertices
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -764,29 +764,25 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
|
|||||||
QVector<GLfloat> circleVertices;
|
QVector<GLfloat> circleVertices;
|
||||||
const float radius = 0.005f * -m_camera->zoom();
|
const float radius = 0.005f * -m_camera->zoom();
|
||||||
const int numSegments = 16;
|
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) {
|
for (const auto& pair : vertexCounts) {
|
||||||
if (pair.second == 1) {
|
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) {
|
for (int i = 0; i < numSegments; ++i) {
|
||||||
float angle1 = (2.0f * M_PI * float(i)) / float(numSegments);
|
float angle1 = (2.0f * M_PI * float(i)) / float(numSegments);
|
||||||
float angle2 = (2.0f * M_PI * float(i + 1)) / 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) {
|
circleVertices << p1.x() << p1.y() << p1.z();
|
||||||
x1 = center.X() + radius * cos(angle1); y1 = center.Y() + radius * sin(angle1); z1 = center.Z();
|
circleVertices << p2.x() << p2.y() << p2.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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user