From 0fa9562f4b737de3f3f46b1c2ed232be2b4252ff Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sat, 1 Aug 2026 12:15:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E7=94=B1=E8=B7=AF=E5=BE=84'?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=89=A9=E4=BD=93'=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=A7=92=E5=BA=A6=E4=BF=AE=E6=AD=A3=E5=92=8C=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E5=81=8F=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MoveObjectToPathStart Free 分支:应用 _objectRotationCorrection (围绕物体中心旋转)后平移到起点;skipCadRestore 时修正已由调用方施加,仅平移 - 泛化 ApplyGroundPathObjectLiftOffset 支持 Free(原本仅 Ground) - '调整物体'窗口对 Free 启用上下偏移输入 - 动画帧循环 Free 分支应用上下偏移 257 单测全过 --- doc/design/2026/free-path-design.md | 19 ++++++++++------- src/Core/Animation/PathAnimationManager.cs | 21 ++++++++++++++++--- .../ViewModels/AnimationControlViewModel.cs | 3 ++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/doc/design/2026/free-path-design.md b/doc/design/2026/free-path-design.md index 2e6ffef..e3dee0b 100644 --- a/doc/design/2026/free-path-design.md +++ b/doc/design/2026/free-path-design.md @@ -144,15 +144,18 @@ framePosition 即物体中心,现有碰撞盒计算直接正确(无需改动 ### 6.1 "调整物体"窗口功能问题 -**状态**:起点姿态、动画已正确;但"调整物体"窗口中的**各种角度调整和姿态调整功能**均存在一些问题,需逐项排查修复。 +**状态**:起点姿态、动画已正确;"调整物体"窗口功能在逐步修复。 -**涉及功能**(待逐项验证): -- 角度调整(X/Y/Z 角度输入) -- 姿态调整(贴合地面、自动调整等) +**已修复**: +- ✅ **X/Y/Z 角度调整**:根因是 `MoveObjectToPathStart` 的 Free 分支只做纯平移, + 忽略了 `_objectRotationCorrection`。已改为先应用角度修正(围绕物体中心旋转) + 再平移到起点;动画帧保留修正后姿态。 +- ✅ **上下偏移(lift)**:泛化 `ApplyGroundPathObjectLiftOffset` 支持 Free; + 窗口对 Free 启用 lift 输入;起点和动画帧均应用偏移。 -**排查方向**(明日): -1. 自由路径物体的姿态链路(宿主空间 vs 内部坐标系) -2. "调整物体"各命令在自由路径下的行为 -3. 与地面/吊装/空轨路径的差异对比 +**待验证**: +- ☐ 自动调整(ObjectPassageProjectionOptimizer) +- ☐ 贴合地面(FaceInfer 流程) +- ☐ 平移到起点 > 进度图例:☐ 未开始 / 🔄 进行中 / ✅ 完成 diff --git a/src/Core/Animation/PathAnimationManager.cs b/src/Core/Animation/PathAnimationManager.cs index 54afe21..9d8d4a0 100644 --- a/src/Core/Animation/PathAnimationManager.cs +++ b/src/Core/Animation/PathAnimationManager.cs @@ -957,11 +957,19 @@ namespace NavisworksTransport.Core.Animation } else if (_route.PathType == PathType.Free) { - // 自由路径:保持物体原始姿态,仅平移到起点(不做任何自动旋转调整) + // 自由路径:应用"调整物体"的角度修正(围绕物体中心旋转)后平移到起点, + // 无修正时保持物体原始姿态。skipCadRestore 时修正已由调用方施加,此处仅平移。 + if (!_objectRotationCorrection.IsZero) + { + ApplyRotationCorrectionInPlace(_objectRotationCorrection); + SyncTrackedStateToCurrentDisplayPose(); + LogManager.Debug($"[移动到起点] 自由路径已应用角度修正: {_objectRotationCorrection}"); + } + startPosition = ApplyGroundPathObjectLiftOffset(startPosition); ApplyTrackedTranslationOnly(startPosition); SyncTrackedRotationToDisplayedPose(CurrentControlledObject ?? _animatedObject); _hasGroundRealObjectBasePose = false; - LogManager.Debug("[移动到起点] 自由路径已保持原始姿态纯平移到起点"); + LogManager.Debug("[移动到起点] 自由路径已应用姿态并平移到起点"); } else if (_route.PathType == PathType.Ground || _route.PathType == PathType.Hoisting) { @@ -1383,6 +1391,11 @@ namespace NavisworksTransport.Core.Animation LogManager.Debug($"[Rail路径] 调整物体位置: 参考点=({p1.X:F2},{p1.Y:F2},{p1.Z:F2})->({p2.X:F2},{p2.Y:F2},{p2.Z:F2}), 物体中心=({framePosition.X:F2},{framePosition.Y:F2},{framePosition.Z:F2}), 安装={_route.RailMountMode}, 参考面={(PathRoute.IsTopReferenceFaceForMountMode(_route.RailMountMode) ? "顶面参考点" : "底面参考点")}"); } } + else if (_route.PathType == PathType.Free) + { + // 自由路径:帧位置 = 路径插值点(物体中心)+ 上下偏移 + framePosition = ApplyGroundPathObjectLiftOffset(framePosition); + } } else { @@ -5686,7 +5699,9 @@ namespace NavisworksTransport.Core.Animation private Point3D ApplyGroundPathObjectLiftOffset(Point3D trackedCenter) { - if (_route == null || _route.PathType != PathType.Ground || Math.Abs(_groundPathObjectLiftHeight) < 1e-9) + if (_route == null || + (_route.PathType != PathType.Ground && _route.PathType != PathType.Free) || + Math.Abs(_groundPathObjectLiftHeight) < 1e-9) { return trackedCenter; } diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index b31533f..1c6dd93 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -2186,7 +2186,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels { try { - bool enableGroundLift = CurrentPathRoute?.PathType == PathType.Ground; + bool enableGroundLift = CurrentPathRoute?.PathType == PathType.Ground || + CurrentPathRoute?.PathType == PathType.Free; var autoAdjustmentRequest = CreateObjectPassageProjectionOptimizationRequest(); LocalEulerRotationCorrection prefillRotation = _objectRotationCorrection; (double, double, double)? prefillAabb = null;