diff --git a/App/editor/ViewportPanel.cpp b/App/editor/ViewportPanel.cpp index 734ffd9..1650780 100644 --- a/App/editor/ViewportPanel.cpp +++ b/App/editor/ViewportPanel.cpp @@ -146,6 +146,13 @@ std::optional ViewportPanel::Draw(const EditorContext &ctx, const ImVec2 mn = ImGui::GetItemRectMin(); ImGuizmo::SetRect(mn.x, mn.y, size.x, size.y); + // 轴可见度阈值(默认 0.02 太小):正对视角下轴投影长度 + // sinθ 在阈值上方 → "看得见但几何上不可操作"——⊥视线 + // 的轴悬停检测失效(射线∥垂直平面,denom=0)、∥视线 + // 的轴拖拽无一阶位移(怎么拖都不动)。UE 语义 = 正对 + // 轴直接隐藏:0.35 ⇒ 夹角 <20° 的轴消失,>20° 可拖 + ImGuizmo::SetPlaneLimit(0.35f); + glm::mat4 m = tr->World(); // 操作空间:local(模型轴,旋转/缩放随物体朝向直观)/ // world(T 键切换)。无父层级时两种模式 world 矩阵同源, @@ -153,17 +160,19 @@ std::optional ViewportPanel::Draw(const EditorContext &ctx, const ImGuizmo::MODE mode = gizmo.localSpace ? ImGuizmo::LOCAL : ImGuizmo::WORLD; - // Ctrl 按住 → 吸附(UE Grid Snap 语义)。ImGuizmo 约定: - // 平移 snap = 世界单位(逐轴)、旋转 = 弧度、缩放 = 步进 + // Ctrl 按住 → 吸附(UE Grid Snap 语义)。库的约定 + //(docs/documentation.md):平移 = 世界单位 float[3] + // 逐轴;旋转 = snap[0] 按度(库内自行 DEG2RAD,传弧度 + // 会被解释成极小步进);缩放 = 只取 snap[0] float snap[3] = {0.0f, 0.0f, 0.0f}; const bool snapping = ImGui::GetIO().KeyCtrl; if (snapping) { if (gizmo.op == ImGuizmo::TRANSLATE) { snap[0] = snap[1] = snap[2] = kSnapTranslate; } else if (gizmo.op == ImGuizmo::ROTATE) { - snap[0] = glm::radians(kSnapRotateDeg); + snap[0] = kSnapRotateDeg; // 度,非弧度 } else if (gizmo.op == ImGuizmo::SCALE) { - snap[0] = snap[1] = snap[2] = kSnapScale; + snap[0] = kSnapScale; } }