From 82caa3e15546da6e89a81b5963038f7a45eb7258 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Tue, 9 Jun 2026 11:37:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B4=B4=E5=90=88=E5=9C=B0=E9=9D=A2?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B7=AF=E5=BE=84yaw=E8=A1=A5=E5=81=BF?= =?UTF-8?q?=EF=BC=8C=E7=89=A9=E4=BD=93=E6=97=8B=E8=BD=AC=E5=90=8E=E9=95=BF?= =?UTF-8?q?=E8=BE=B9=E5=AF=B9=E9=BD=90=E8=B7=AF=E5=BE=84=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/AnimationControlViewModel.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index 1979276..4e8473a 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -2299,6 +2299,34 @@ namespace NavisworksTransport.UI.WPF.ViewModels else if (d < -0.9999f) overrideQ = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)Math.PI); else overrideQ = Quaternion.CreateFromAxisAngle(Vector3.Normalize(Vector3.Cross(cadWorldN, t)), (float)Math.Acos(d)); + // 路径 yaw 补偿 + var routePoints = CurrentPathRoute?.Points; + if ((CurrentPathRoute?.PathType == PathType.Ground || CurrentPathRoute?.PathType == PathType.Hoisting) + && routePoints != null && routePoints.Count >= 2) + { + // 照抄 TryResolveStartPathDirection 的取点方式 + var start = routePoints[0]; + var startVector = new Vector3((float)start.X, (float)start.Y, (float)start.Z); + Vector3 hostForward = Vector3.Zero; + for (int i = 1; i < routePoints.Count; i++) + { + var point = routePoints[i]; + var candidate = new Vector3((float)point.X, (float)point.Y, (float)point.Z) - startVector; + if (candidate.LengthSquared() > 1e-8f) + { + hostForward = candidate; + break; + } + } + if (hostForward.LengthSquared() > 1e-8f + && PathTargetFrameResolver.TryResolvePlanarHostYaw( + hostForward, CoordinateSystemManager.Instance.ResolvedType, out double yawRadians)) + { + overrideQ = Quaternion.Normalize( + Quaternion.CreateFromAxisAngle(adapter.HostUpVector3, (float)yawRadians) * overrideQ); + } + } + var center = item.BoundingBox().Center; var tp = new Vector3((float)center.X, (float)center.Y, (float)center.Z); var rtp = Vector3.Transform(tp, overrideQ);