From b939da103644fd9aec9b3c8c86ee668d5d1aea56 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 16 Oct 2015 12:36:09 -0700 Subject: [PATCH] fixed a bug with group objects moving on the be when scaled. --- PartPreviewWindow/View3D/View3DWidget.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index e44fcae63..ef9dda479 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -2151,6 +2151,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void ScaleAxis(double scaleIn, int axis) { AxisAlignedBoundingBox originalMeshBounds = SelectedMeshGroup.GetAxisAlignedBoundingBox(); + + AxisAlignedBoundingBox totalMeshBounds = SelectedMeshGroup.GetAxisAlignedBoundingBox(SelectedMeshGroupTransform.TotalTransform); + AxisAlignedBoundingBox scaledBounds = SelectedMeshGroup.GetAxisAlignedBoundingBox(SelectedMeshGroupTransform.scale); // first we remove any scale we have applied and then scale to the new value @@ -2169,7 +2172,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow scale.scale *= totalScale; SelectedMeshGroupTransform = scale; + // And make sure its center has not changed + AxisAlignedBoundingBox postScaleBounds = SelectedMeshGroup.GetAxisAlignedBoundingBox(SelectedMeshGroupTransform.TotalTransform); + ScaleRotateTranslate translation = SelectedMeshGroupTransform; + translation.translation *= Matrix4X4.CreateTranslation(totalMeshBounds.Center - postScaleBounds.Center); + SelectedMeshGroupTransform = translation; + PlatingHelper.PlaceMeshGroupOnBed(MeshGroups, MeshGroupTransforms, SelectedMeshGroupIndex); + PartHasBeenChanged(); Invalidate(); MeshGroupExtraData[SelectedMeshGroupIndex].currentScale[axis] = scaleIn;