feat: Implement Z-up coordinate system for camera and sketches
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -98,6 +98,8 @@ QMatrix4x4 Camera::modelViewMatrix() const
|
|||||||
if (m_isRotating) {
|
if (m_isRotating) {
|
||||||
model.translate(-m_rotationPivot);
|
model.translate(-m_rotationPivot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.rotate(-90.0f, 1, 0, 0); // For Z-up system
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -489,8 +489,8 @@ QVector3D ViewportWidget::unproject(const QPoint& screenPos, SketchPlane plane)
|
|||||||
|
|
||||||
QVector3D planeNormal;
|
QVector3D planeNormal;
|
||||||
switch (plane) {
|
switch (plane) {
|
||||||
case SketchPlane::XY: planeNormal = QVector3D(0, 1, 0); break;
|
case SketchPlane::XY: planeNormal = QVector3D(0, 0, 1); break;
|
||||||
case SketchPlane::XZ: planeNormal = QVector3D(0, 0, 1); break;
|
case SketchPlane::XZ: planeNormal = QVector3D(0, 1, 0); break;
|
||||||
case SketchPlane::YZ: planeNormal = QVector3D(1, 0, 0); break;
|
case SketchPlane::YZ: planeNormal = QVector3D(1, 0, 0); break;
|
||||||
case SketchPlane::NONE: return QVector3D();
|
case SketchPlane::NONE: return QVector3D();
|
||||||
}
|
}
|
||||||
@@ -532,15 +532,15 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
|
|||||||
const int numSegments = 64;
|
const int numSegments = 64;
|
||||||
QVector3D u_axis, v_axis;
|
QVector3D u_axis, v_axis;
|
||||||
switch (sketch->plane()) {
|
switch (sketch->plane()) {
|
||||||
case SketchFeature::SketchPlane::XY:
|
case SketchFeature::SketchPlane::XY: // Top
|
||||||
u_axis = QVector3D(1, 0, 0);
|
|
||||||
v_axis = QVector3D(0, 0, 1);
|
|
||||||
break;
|
|
||||||
case SketchFeature::SketchPlane::XZ:
|
|
||||||
u_axis = QVector3D(1, 0, 0);
|
u_axis = QVector3D(1, 0, 0);
|
||||||
v_axis = QVector3D(0, 1, 0);
|
v_axis = QVector3D(0, 1, 0);
|
||||||
break;
|
break;
|
||||||
case SketchFeature::SketchPlane::YZ:
|
case SketchFeature::SketchPlane::XZ: // Front
|
||||||
|
u_axis = QVector3D(1, 0, 0);
|
||||||
|
v_axis = QVector3D(0, 0, 1);
|
||||||
|
break;
|
||||||
|
case SketchFeature::SketchPlane::YZ: // Right
|
||||||
u_axis = QVector3D(0, 1, 0);
|
u_axis = QVector3D(0, 1, 0);
|
||||||
v_axis = QVector3D(0, 0, 1);
|
v_axis = QVector3D(0, 0, 1);
|
||||||
break;
|
break;
|
||||||
@@ -564,10 +564,10 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
|
|||||||
gp_Pnt p2, p4;
|
gp_Pnt p2, p4;
|
||||||
if (sketch->plane() == SketchFeature::SketchPlane::XY) {
|
if (sketch->plane() == SketchFeature::SketchPlane::XY) {
|
||||||
p2.SetCoord(p3.X(), p1.Y(), p1.Z());
|
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) {
|
} else if (sketch->plane() == SketchFeature::SketchPlane::XZ) {
|
||||||
p2.SetCoord(p3.X(), p1.Y(), p1.Z());
|
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) {
|
} else if (sketch->plane() == SketchFeature::SketchPlane::YZ) {
|
||||||
p2.SetCoord(p1.X(), p3.Y(), p1.Z());
|
p2.SetCoord(p1.X(), p3.Y(), p1.Z());
|
||||||
p4.SetCoord(p1.X(), p1.Y(), p3.Z());
|
p4.SetCoord(p1.X(), p1.Y(), p3.Z());
|
||||||
|
|||||||
Reference in New Issue
Block a user