优化物体选择逻辑,增加角度修正值的直接设置,确保选择相同物体时保持当前角度修正值
This commit is contained in:
parent
ca503c0448
commit
be9131b89f
@ -2541,6 +2541,16 @@ namespace NavisworksTransport.Core.Animation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 直接设置物体角度修正值(不触发物体旋转)
|
||||
/// </summary>
|
||||
/// <param name="rotationCorrection">角度修正值(度)</param>
|
||||
public void SetObjectRotationCorrectionDirect(double rotationCorrection)
|
||||
{
|
||||
_objectRotationCorrection = rotationCorrection;
|
||||
LogManager.Debug($"[角度修正] 直接设置角度修正值: {_objectRotationCorrection:F1}°(不触发旋转)");
|
||||
}
|
||||
|
||||
#region 动画实现方法
|
||||
|
||||
|
||||
@ -2800,6 +2810,10 @@ namespace NavisworksTransport.Core.Animation
|
||||
sb.Append(vehicleSizeString);
|
||||
sb.Append("|");
|
||||
|
||||
// 包含角度修正(确保角度修正改变时重新检测)
|
||||
sb.Append($"RotationCorrection:{_objectRotationCorrection:F2}deg");
|
||||
sb.Append("|");
|
||||
|
||||
// 包含手工检测对象列表(确保手工指定模式的目标变化时重新检测)
|
||||
if (_manualCollisionOverrideEnabled && _manualCollisionTargets != null && _manualCollisionTargets.Count > 0)
|
||||
{
|
||||
|
||||
@ -1326,9 +1326,10 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
|
||||
// 1. 保存旧物体引用,在设置新物体之前
|
||||
var oldObject = _selectedAnimatedObject;
|
||||
bool isSameObject = oldObject != null && ReferenceEquals(oldObject, newObject);
|
||||
|
||||
// 2. 如果有旧物体且与新物体不同,先归位
|
||||
if (oldObject != null && !ReferenceEquals(oldObject, newObject))
|
||||
if (!isSameObject && oldObject != null)
|
||||
{
|
||||
_pathAnimationManager?.RestoreObjectToCADPosition();
|
||||
LogManager.Info($"[选择物体] 已归位旧物体: {oldObject.DisplayName}");
|
||||
@ -1347,8 +1348,16 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
SelectedAnimatedObject = newObject;
|
||||
LogManager.Info($"已选择移动物体: {SelectedAnimatedObject.DisplayName}");
|
||||
|
||||
// 重置PathAnimationManager的角度修正值(每个物体的旋转独立)
|
||||
_pathAnimationManager?.SetObjectRotationCorrection(0.0);
|
||||
// 只有选择不同的物体时,才重置角度修正值
|
||||
if (!isSameObject)
|
||||
{
|
||||
_pathAnimationManager?.SetObjectRotationCorrectionDirect(0.0);
|
||||
LogManager.Debug($"[选择物体] 已重置角度修正值为0度(新物体)");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManager.Debug($"[选择物体] 保持当前角度修正值(同一物体)");
|
||||
}
|
||||
|
||||
// 3. 立即移动到起点(如果路径存在)
|
||||
if (CurrentPathRoute != null && CurrentPathRoute.Points != null && _pathAnimationManager != null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user