refactor: 起点放置按两步架构分离(调整物体统一 + 路径对齐各自处理)

按架构原则重构 MoveObjectToPathStart 和 PreservingInitialPose:
- 第二步:路径起点位置对齐(各路径类型各自处理,不含 lift)
- 第一步:调整物体的上下偏移(统一应用,路径无关,无分支)
- Rail 因流程提前返回(三维姿态就地应用),lift 在其分支内应用
- 更新设计文档记录架构原则
257 单测全过
This commit is contained in:
tian 2026-08-01 12:56:11 +08:00
parent fc8ff51ae1
commit 53ae232ebc
2 changed files with 17 additions and 9 deletions

View File

@ -8,6 +8,12 @@
> - 决策点1旋转姿态**最终改为 —— 自由路径保持物体原始姿态**,不自动对齐路径方向
> (真实物体/YUp 的自动姿态解析易出错;用户通过"调整物体"控制朝向)
> - 决策点2旧数据迁移方案A —— 自动转换 IsTwoPointVertical → Free
>
> **架构原则2026-08**"调整物体"只是调整物体的**姿态修正 + 上下偏移**
> 与路径对齐无关。物体在起点的姿态/位置由两个分离步骤决定:
> - **第一步(统一,路径无关,无分支)**:调整物体的结果(姿态修正 X/Y/Z + 上下偏移 lift
> - **第二步(各路径自己的处理逻辑)**:路径起点对齐(路径点→物体位置 + 基座姿态对齐)
> 所有路径都遵循此架构;只有第二步允许分支。
---

View File

@ -802,20 +802,18 @@ namespace NavisworksTransport.Core.Animation
IsRealObjectMode &&
(_route.PathType == PathType.Ground || _route.PathType == PathType.Hoisting || _route.PathType == PathType.Free);
// 根据路径类型调整起点位置
// ===== 第二步:路径起点位置对齐(各路径类型各自处理,不含 lift=====
Point3D pathStartPoint = _pathPoints[0];
Point3D startPosition = pathStartPoint;
if (_route.PathType == PathType.Free)
{
// 自由路径路径点即物体几何中心再叠加上下偏移lift
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
// 自由路径:路径点即物体几何中心
LogManager.Debug($"[移动到起点] 自由路径:路径点即物体中心=({startPosition.X:F2},{startPosition.Y:F2},{startPosition.Z:F2})");
}
else if (_route.PathType == PathType.Hoisting)
{
// 吊装路径:第一个路径点(起吊点)是地面位置,动画跟踪点统一使用几何中心
startPosition = ResolveGroundTrackedCenter(startPosition, GetAnimatedObjectGroundContactHeight());
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
LogManager.Debug($"[移动到起点] 吊装路径:起吊点已转换为物体中心=({startPosition.X:F2},{startPosition.Y:F2},{startPosition.Z:F2})");
}
else if (_route.PathType == PathType.Rail)
@ -835,8 +833,8 @@ namespace NavisworksTransport.Core.Animation
startPosition = RailPathPoseHelper.ResolveObjectSpaceCenterPosition(_route, startPosition, previousPoint, nextPoint, objectHeight);
LogManager.Debug($"[移动到起点] Rail路径调整: 参考点=({_pathPoints[0].X:F2},{_pathPoints[0].Y:F2},{_pathPoints[0].Z:F2}), 物体中心=({startPosition.X:F2},{startPosition.Y:F2},{startPosition.Z:F2}), 物体高度={objectHeight:F2}, 安装={_route.RailMountMode}, 参考面={(PathRoute.IsTopReferenceFaceForMountMode(_route.RailMountMode) ? "" : "")}");
}
// Rail 流程提前返回(三维姿态就地应用),在此应用第一步的上下偏移
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
if (TryCreateRailPathRotation(
previousPoint,
_pathPoints[0],
@ -859,10 +857,13 @@ namespace NavisworksTransport.Core.Animation
{
// 地面路径:路径点在接触面上,动画跟踪点统一使用几何中心
startPosition = ResolveGroundTrackedCenter(startPosition, GetAnimatedObjectGroundContactHeight());
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
LogManager.Debug($"[移动到起点] 地面路径中心点=({startPosition.X:F2},{startPosition.Y:F2},{startPosition.Z:F2})");
}
// ===== 第一步:调整物体的结果——上下偏移(统一,路径无关)=====
// 注Rail 因流程提前返回三维姿态就地应用lift 在其分支内应用
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
LogManager.Debug(
$"[路径起点诊断] 路径point0=({pathStartPoint.X:F3},{pathStartPoint.Y:F3},{pathStartPoint.Z:F3}), " +
$"起点目标trackedPoint=({startPosition.X:F3},{startPosition.Y:F3},{startPosition.Z:F3}), 路径类型={_route.PathType.GetDisplayName()}");
@ -1051,8 +1052,7 @@ namespace NavisworksTransport.Core.Animation
Point3D startPosition = pathStartPoint;
if (_route.PathType == PathType.Free)
{
// 自由路径:路径点即物体几何中心,无需半高偏移,仅叠加上下偏移
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
// 自由路径:路径点即物体几何中心,无需半高偏移
}
else if (_route.PathType == PathType.Hoisting)
{
@ -1086,9 +1086,11 @@ namespace NavisworksTransport.Core.Animation
else
{
startPosition = ResolveGroundTrackedCenter(startPosition, GetAnimatedObjectGroundContactHeight());
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
}
// 第一步:调整物体的结果——上下偏移(统一,路径无关)
startPosition = ApplyGroundPathObjectLiftOffset(startPosition);
ApplyTrackedTranslationOnly(startPosition);
SyncTrackedRotationToDisplayedPose(CurrentControlledObject ?? _animatedObject);
_hasGroundRealObjectBasePose = false;