From fef23f8ca660d21cba7ca8f90a3acaccd655581f Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 23 Jan 2018 16:56:15 -0800 Subject: [PATCH] Fixed problem dragging onto bed when plane can't be found initially --- DesignTools/PubicPropertyEditor.cs | 5 +--- PartPreviewWindow/View3D/View3DWidget.cs | 32 +++++++++++++++++------- Submodules/agg-sharp | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/DesignTools/PubicPropertyEditor.cs b/DesignTools/PubicPropertyEditor.cs index c561be4cc..939736aed 100644 --- a/DesignTools/PubicPropertyEditor.cs +++ b/DesignTools/PubicPropertyEditor.cs @@ -73,10 +73,7 @@ namespace MatterHackers.MatterControl.DesignTools return mainContainer; } - public IEnumerable SupportedTypes() => new Type[] - { - typeof(CanRebuildObject3D), - }; + public IEnumerable SupportedTypes() => new Type[] { typeof(CanRebuildObject3D) }; private static FlowLayoutWidget CreateSettingsRow(string labelText) { diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 771e23b8d..f7e8e1c27 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -621,15 +621,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var intersectInfo = GetIntersectPosition(screenSpaceMousePosition); if (intersectInfo != null) { - // Set the initial transform on the inject part to the current transform mouse position - var sourceItemBounds = insertionGroup.GetAxisAlignedBoundingBox(Matrix4X4.Identity); - var center = sourceItemBounds.Center; - - insertionGroup.Matrix *= Matrix4X4.CreateTranslation(-center.X, -center.Y, -sourceItemBounds.minXYZ.Z); - insertionGroup.Matrix *= Matrix4X4.CreateTranslation(new Vector3(intersectInfo.HitPosition)); - - CurrentSelectInfo.PlaneDownHitPos = intersectInfo.HitPosition; - CurrentSelectInfo.LastMoveDelta = Vector3.Zero; + CalculateDragStartPosition(insertionGroup, intersectInfo); + } + else + { + CurrentSelectInfo.LastMoveDelta = Vector3.PositiveInfinity; } this.deferEditorTillMouseUp = true; @@ -644,6 +640,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.DragDropObject = insertionGroup; } + private void CalculateDragStartPosition(IObject3D insertionGroup, IntersectInfo intersectInfo) + { + // Set the initial transform on the inject part to the current transform mouse position + var sourceItemBounds = insertionGroup.GetAxisAlignedBoundingBox(Matrix4X4.Identity); + var center = sourceItemBounds.Center; + + insertionGroup.Matrix *= Matrix4X4.CreateTranslation(-center.X, -center.Y, -sourceItemBounds.minXYZ.Z); + insertionGroup.Matrix *= Matrix4X4.CreateTranslation(new Vector3(intersectInfo.HitPosition)); + + CurrentSelectInfo.PlaneDownHitPos = intersectInfo.HitPosition; + CurrentSelectInfo.LastMoveDelta = Vector3.Zero; + } + internal void FinishDrop(bool mouseUpInBounds) { if (this.DragOperationActive) @@ -1035,6 +1044,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow IntersectInfo info = CurrentSelectInfo.HitPlane.GetClosestIntersection(ray); if (info != null) { + if (CurrentSelectInfo.LastMoveDelta == Vector3.PositiveInfinity) + { + CalculateDragStartPosition(Scene.SelectedItem, info); + } + // move the mesh back to the start position { Matrix4X4 totalTransform = Matrix4X4.CreateTranslation(new Vector3(-CurrentSelectInfo.LastMoveDelta)); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 80c1e9311..7c227e848 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 80c1e9311d8f877fca0bcfc92289d58a936f712c +Subproject commit 7c227e8487d6432dd0b0db7b380f93d946e5faa4