From d1d71f960355d0270fbbb45ed0eb73e8a9e6af50 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Wed, 11 Jul 2018 07:37:43 -0700 Subject: [PATCH] Making fit to bounds recalculate aabb when matrix changes issue: MatterHackers/MCCentral#3831 Fit to bounds has bad rotation axis' after being moved --- DesignTools/Obsolete/FitToBoundsObject3D.cs | 2 +- DesignTools/Operations/FitToBoundsObject3D_2.cs | 13 ++++++++++--- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DesignTools/Obsolete/FitToBoundsObject3D.cs b/DesignTools/Obsolete/FitToBoundsObject3D.cs index 7992051e9..4b6393c84 100644 --- a/DesignTools/Obsolete/FitToBoundsObject3D.cs +++ b/DesignTools/Obsolete/FitToBoundsObject3D.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public double Width { get; set; } public double Depth { get; set; } public double Diameter { get; set; } - public double Height { get; set; } + public double Height { get; set; } [Description("Set the rules for how to maintain the part while scaling.")] public MaintainRatio MaintainRatio { get; set; } = MaintainRatio.X_Y; diff --git a/DesignTools/Operations/FitToBoundsObject3D_2.cs b/DesignTools/Operations/FitToBoundsObject3D_2.cs index bd6a5d158..1dce1c952 100644 --- a/DesignTools/Operations/FitToBoundsObject3D_2.cs +++ b/DesignTools/Operations/FitToBoundsObject3D_2.cs @@ -49,7 +49,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations private Vector3 cacheBounds; - private Matrix4X4 cacheMatrix; + private Matrix4X4 cacheParentMatrix; + private Matrix4X4 cacheThisMatrix; public FitToBoundsObject3D_2() { @@ -110,7 +111,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { if (Children.Count == 2) { - if (cacheMatrix != matrix + if (cacheParentMatrix != matrix + || cacheThisMatrix != Matrix || cacheBounds != boundsSize) { using (FitBounds.RebuildLock()) @@ -119,7 +121,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations cacheAabb = base.GetAxisAlignedBoundingBox(matrix); FitBounds.Visible = false; } - cacheMatrix = matrix; + cacheParentMatrix = matrix; + cacheThisMatrix = Matrix; cacheBounds = boundsSize; } @@ -144,6 +147,10 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { Rebuild(null); } + else if(invalidateType.InvalidateType == InvalidateType.Matrix) + { + cacheThisMatrix = Matrix4X4.Identity; + } else { base.OnInvalidate(invalidateType); diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index a294e6772..25566d561 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit a294e67725162baedc55a40570d197f3f60d6e3c +Subproject commit 25566d561cf4431d0d1536c4eb70ae008924233e diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 83a061238..222d93bbf 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 83a061238145ccde64e2effc10e55468b39b5b8d +Subproject commit 222d93bbf054ab869c073b9d8810011b73d3d1af