Fixing bad intersection tests on close geometry

This commit is contained in:
Lars Brubaker 2022-11-04 11:38:09 -07:00
parent 8cac6069b4
commit 3a5cf179fd
3 changed files with 15 additions and 8 deletions

View file

@ -504,9 +504,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
"Cancel Print".Localize(),
"Continue Printing".Localize());
}
else if (this.TabContent is DesignTabPage partTab
&& partTab?.Workspace?.SceneContext?.Scene is InteractiveScene scene
&& scene.HasUnsavedChanges)
else if (this.TabContent is DesignTabPage partTab // we are a part tap
&& partTab?.Workspace?.SceneContext is ISceneContext sceneContext // we have a context
&& sceneContext.Scene is InteractiveScene scene // we have a scene
&& scene.HasUnsavedChanges // we have unsaved changes
&& (sceneContext.EditContext.ContentStore != null || scene.Descendants().Count() > 0)) // we are not an unsaved empty tab (new with only deleting phil)
{
StyledMessageBox.ShowYNCMessageBox(
(response) =>
@ -516,7 +518,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
case StyledMessageBox.ResponseType.YES:
UiThread.RunOnIdle(async () =>
{
var sceneContext = partTab.Workspace.SceneContext;
if (sceneContext.EditContext.ContentStore == null)
{
// If we are about to close a tab that has never been saved it will need a name before it can actually save

View file

@ -2224,6 +2224,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
foreach (var object3D in Scene.Children)
{
if (object3D.GetBVHData().Contains(intersectionInfo.HitPosition))
{
// run the same hit on this object only and see if is still the same position
var singleObjectIntersection = object3D.GetBVHData().GetClosestIntersection(ray);
if (singleObjectIntersection != null
&& singleObjectIntersection.HitPosition == intersectionInfo.HitPosition)
{
CurrentSelectInfo.PlaneDownHitPos = intersectionInfo.HitPosition;
CurrentSelectInfo.LastMoveDelta = default(Vector3);
@ -2231,6 +2236,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
}
}
return null;
}

@ -1 +1 @@
Subproject commit 03768ac1437d052a39a0945204e80625ad1cad80
Subproject commit 4008f642a465afdc229322751629391b8a729507