0.15.3: auto-adjust uses optimizer AABB directly for passage space visualization

- Optimizer now returns AABB extents (sx, sy, sz) from measured object
- UpdatePassageSpaceVisualization uses optimizer AABB directly:
  Forward=sx, Width=sz, Height=sy - no cuboid projection needed
- Fixed negative passageNormalToPath when lift offset is negative
- Removed host-axis cuboid projection from TryCalculateCurrentRealObjectPlanarProjectedExtents
This commit is contained in:
tian 2026-05-30 02:48:39 +08:00
parent b25a3a04a1
commit 1ca2a8e1bc
3 changed files with 34 additions and 7 deletions

View File

@ -359,6 +359,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 角度修正相关字段
private LocalEulerRotationCorrection _objectRotationCorrection = LocalEulerRotationCorrection.Zero; // 物体绕宿主 X/Y/Z 轴的角度修正
private double _objectGroundLiftHeightInMeters;
private double? _autoAabbSx, _autoAabbSy, _autoAabbSz;
// 移动物体原始尺寸(米,在选择物体时保存)
private double _objectOriginalLength; // 物体原始长度X方向
@ -2189,6 +2190,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
_objectGroundLiftHeightInMeters = placementRequest.VerticalLiftInMeters;
_pathAnimationManager?.ApplyObjectStartPlacementRequest(placementRequest);
ObjectRotationCorrection = placementRequest.RotationCorrection;
if (dialog.AutoAdjustAabbSizes.HasValue)
(_autoAabbSx, _autoAabbSy, _autoAabbSz) = dialog.AutoAdjustAabbSizes.Value;
string liftSummary = enableGroundLift
? $", 上下偏移={_objectGroundLiftHeightInMeters:F3}m"
@ -2281,7 +2284,10 @@ namespace NavisworksTransport.UI.WPF.ViewModels
double neededLiftModelUnits = groundLevel + request.VehicleHeightModelUnits - objectBottomWorld;
result = ObjectPassageProjectionOptimizationResult.CreateSuccess(
result.Correction, result.Score, neededLiftModelUnits);
result.Correction, result.Score, neededLiftModelUnits,
measureBounds.Max.X - measureBounds.Min.X,
measureBounds.Max.Y - measureBounds.Min.Y,
measureBounds.Max.Z - measureBounds.Min.Z);
LogManager.Debug(
$"[自动调整] 物体底面={objectBottomWorld:F3}, 地面={groundLevel:F3}, " +
@ -4724,7 +4730,18 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
// 计算旋转后的有效尺寸(考虑角度修正)
(double effectiveLength, double effectiveWidth, double effectiveHeight) = CalculateRotatedDimensions();
double effectiveLength, effectiveWidth, effectiveHeight;
if (_autoAabbSx.HasValue)
{
effectiveLength = _autoAabbSx.Value;
effectiveWidth = _autoAabbSz.Value;
effectiveHeight = _autoAabbSy.Value;
_autoAabbSx = null;
}
else
{
(effectiveLength, effectiveWidth, effectiveHeight) = CalculateRotatedDimensions();
}
var renderPlugin = PathPointRenderPlugin.Instance;
if (renderPlugin == null)
@ -4758,7 +4775,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 地面路径物体的长度方向X轴前进方向朝向路径方向
// 通行空间沿路径方向 = X方向尺寸长度垂直于路径方向 = Y方向尺寸宽度高度上方加间隙下方不需要因为有地面
passageAcrossPath = effectiveWidth + 2 * safetyMargin; // 旋转后宽度 + 2*间隙(垂直于路径方向)
passageNormalToPath = effectiveHeight + (_objectGroundLiftHeightInMeters * metersToUnitsPassage) + safetyMargin; // 物体高度 + 上下偏移 + 上方间隙
passageNormalToPath = effectiveHeight + safetyMargin + Math.Max(0, _objectGroundLiftHeightInMeters * metersToUnitsPassage); // 负lift不压缩高度
passageAlongPath = effectiveLength; // 旋转后长度(沿路径方向)
// 地面路径不需要分段参数
passageNormalToPathVertical = passageNormalToPath;
@ -4802,7 +4819,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 物体的长度方向X轴前进方向朝向路径方向
// 通行空间沿路径方向 = X方向尺寸长度垂直于路径方向 = Y方向尺寸宽度高度上方加间隙下方不需要因为有地面
passageAcrossPath = effectiveWidth + 2 * safetyMargin; // 旋转后宽度 + 2*间隙(垂直于路径方向)
passageNormalToPath = effectiveHeight + (_objectGroundLiftHeightInMeters * metersToUnitsPassage) + safetyMargin; // 物体高度 + 上下偏移 + 上方间隙
passageNormalToPath = effectiveHeight + safetyMargin + Math.Max(0, _objectGroundLiftHeightInMeters * metersToUnitsPassage); // 物体高度 + 上方间隙负lift不压缩高度
passageAlongPath = effectiveLength; // 旋转后长度(沿路径方向)
// 地面路径不需要分段参数
passageNormalToPathVertical = passageNormalToPath;

View File

@ -40,6 +40,8 @@ namespace NavisworksTransport.UI.WPF.Views
set => _requireWidthLarger = value;
}
public (double sx, double sy, double sz)? AutoAdjustAabbSizes { get; private set; }
public double VehicleHeightInMeters
{
get => _vehicleHeightInMeters;
@ -188,6 +190,8 @@ namespace NavisworksTransport.UI.WPF.Views
{
GroundPathLiftHeightInMeters = Math.Round(UnitsConverter.ConvertToMeters(result.ComputedLiftOffsetModelUnits.Value), 3);
}
if (result.AabbSx.HasValue)
AutoAdjustAabbSizes = (result.AabbSx.Value, result.AabbSy.Value, result.AabbSz.Value);
LogManager.Debug(
$"[自动调整] 已写入角度: {RotationCorrection}, " +
$"截面宽度={result.Score.WidthAcrossPath:F3}, 高度={result.Score.HeightAlongHostUp:F3}, 面积={result.Score.Area:F3}");

View File

@ -56,13 +56,15 @@ namespace NavisworksTransport.Utils.CoordinateSystem
LocalEulerRotationCorrection correction,
ObjectPassageProjectionScore score,
string errorMessage,
double? computedLiftOffsetModelUnits = null)
double? computedLiftOffsetModelUnits = null,
double? aabbSx = null, double? aabbSy = null, double? aabbSz = null)
{
Success = success;
Correction = correction;
Score = score;
ErrorMessage = errorMessage;
ComputedLiftOffsetModelUnits = computedLiftOffsetModelUnits;
AabbSx = aabbSx; AabbSy = aabbSy; AabbSz = aabbSz;
}
public bool Success { get; }
@ -77,13 +79,17 @@ namespace NavisworksTransport.Utils.CoordinateSystem
/// 自动调整后计算出的上下偏移(模型单位),使物体底面贴合物流车高度。仅地面路径有效。
/// </summary>
public double? ComputedLiftOffsetModelUnits { get; }
public double? AabbSx { get; }
public double? AabbSy { get; }
public double? AabbSz { get; }
public static ObjectPassageProjectionOptimizationResult CreateSuccess(
LocalEulerRotationCorrection correction,
ObjectPassageProjectionScore score,
double? computedLiftOffsetModelUnits = null)
double? computedLiftOffsetModelUnits = null,
double? aabbSx = null, double? aabbSy = null, double? aabbSz = null)
{
return new ObjectPassageProjectionOptimizationResult(true, correction, score, null, computedLiftOffsetModelUnits);
return new ObjectPassageProjectionOptimizationResult(true, correction, score, null, computedLiftOffsetModelUnits, aabbSx, aabbSy, aabbSz);
}
public static ObjectPassageProjectionOptimizationResult CreateFailure(string errorMessage)