Fixed problem dragging onto bed when plane can't be found initially

This commit is contained in:
Lars Brubaker 2018-01-23 16:56:15 -08:00
parent 5ee0a00e8b
commit fef23f8ca6
3 changed files with 25 additions and 14 deletions

View file

@ -73,10 +73,7 @@ namespace MatterHackers.MatterControl.DesignTools
return mainContainer;
}
public IEnumerable<Type> SupportedTypes() => new Type[]
{
typeof(CanRebuildObject3D),
};
public IEnumerable<Type> SupportedTypes() => new Type[] { typeof(CanRebuildObject3D) };
private static FlowLayoutWidget CreateSettingsRow(string labelText)
{

View file

@ -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));

@ -1 +1 @@
Subproject commit 80c1e9311d8f877fca0bcfc92289d58a936f712c
Subproject commit 7c227e8487d6432dd0b0db7b380f93d946e5faa4