From 8438d809aed53790be1e86d1489f0bdecbc21f23 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Thu, 4 Sep 2025 01:47:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=87=8D=E5=A4=8D=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Collision/ClashDetectiveIntegration.cs | 40 ++++++++++++++----- .../ViewModels/AnimationControlViewModel.cs | 4 ++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/Core/Collision/ClashDetectiveIntegration.cs b/src/Core/Collision/ClashDetectiveIntegration.cs index 453800e..b8939b2 100644 --- a/src/Core/Collision/ClashDetectiveIntegration.cs +++ b/src/Core/Collision/ClashDetectiveIntegration.cs @@ -183,19 +183,39 @@ namespace NavisworksTransport { try { - // 首先检查是否已经存在同名测试,如果存在则删除 - var existingTest = _documentClash.TestsData.Tests.FirstOrDefault(t => t.DisplayName == "动态运输路径碰撞检测"); - if (existingTest != null) + // 清理所有动画相关的测试(包括之前创建的"动画路径碰撞_X"测试) + var existingAnimationTests = _documentClash.TestsData.Tests + .Where(t => t.DisplayName.StartsWith("动态运输路径碰撞检测") || + t.DisplayName.StartsWith("动画路径碰撞")) + .ToList(); + + if (existingAnimationTests.Any()) { - LogManager.Info("删除已存在的动态测试"); - if (existingTest is ClashTest existingClashTest) + LogManager.Info($"发现 {existingAnimationTests.Count} 个需要清理的动画测试"); + int removedCount = 0; + + foreach (var test in existingAnimationTests) { - _documentClash.TestsData.TestsRemove(existingClashTest); - } - else - { - LogManager.Warning("找到的测试不是ClashTest类型,无法删除"); + if (test is ClashTest testToRemove) + { + try + { + _documentClash.TestsData.TestsRemove(testToRemove); + removedCount++; + LogManager.Debug($"已删除测试: {test.DisplayName}"); + } + catch (Exception ex) + { + LogManager.Warning($"删除测试失败 {test.DisplayName}: {ex.Message}"); + } + } } + + LogManager.Info($"成功清理了 {removedCount} 个旧的动画碰撞测试"); + } + else + { + LogManager.Info("未发现需要清理的旧动画测试"); } // 创建新的碰撞测试 diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index 8c0541f..876b173 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -557,6 +557,10 @@ namespace NavisworksTransport.UI.WPF.ViewModels } // 开始播放物体移动动画 + // 清理之前的碰撞缓存 + _logisticsAnimationManager?.ClearExclusionCache(); + LogManager.Info("已清理UI层碰撞检测缓存"); + // 首先重置进度(开始全新动画时) await _uiStateManager.ExecuteUIUpdateAsync(() => {