Refactoring to use ITraceable preferentially to IPrimitive
This commit is contained in:
parent
52df1380a7
commit
6e682494de
16 changed files with 145 additions and 128 deletions
|
|
@ -270,6 +270,11 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
}
|
||||
}
|
||||
|
||||
public ITraceable GetTraceable()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private class CurveControlPoint : VertexPointWidget
|
||||
{
|
||||
public CurveControlPoint(IObject3DControlContext context, PathControl pathControl, VertexStorage vertexStorage, Vector3 point, ShapePath.FlagsAndCommand flagsandCommand, int index)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
Invalidate();
|
||||
};
|
||||
|
||||
object3DControlContext.GuiSurface.AddChild(angleTextControl);
|
||||
Object3DControlContext.GuiSurface.AddChild(angleTextControl);
|
||||
|
||||
angleTextControl.EditComplete += (s, e) =>
|
||||
{
|
||||
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
lastSnappedRotation = SnappedRotationAngle;
|
||||
}
|
||||
|
||||
object3DControlContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
CollisionVolume = rotationHandle.CreateBVHData();
|
||||
|
||||
object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
Object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
}
|
||||
|
||||
public int RotationAxis { get; private set; }
|
||||
|
|
@ -182,7 +182,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
RenderOpenGl.ImageGlPlugin.GetImageGlPlugin(rotationImageWhite, true);
|
||||
|
||||
// We only draw the rotation arrows when the user has not selected any Object3DControl volumes (they are not actively scaling or rotating anything).
|
||||
if (object3DControlContext.SelectedObject3DControl == null)
|
||||
if (Object3DControlContext.SelectedObject3DControl == null)
|
||||
{
|
||||
var color = MouseIsOver ? theme.PrimaryAccentColor : theme.TextColor;
|
||||
GLHelper.Render(rotationHandle, new Color(color, 254), TotalTransform, RenderTypes.Shaded);
|
||||
|
|
@ -221,7 +221,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
for (int cornerIndex = 0; cornerIndex < 4; cornerIndex++)
|
||||
{
|
||||
Vector3 cornerPosition = currentSelectedBounds.GetBottomCorner(cornerIndex);
|
||||
Vector3 cornerScreenSpace = object3DControlContext.World.GetScreenSpace(cornerPosition);
|
||||
Vector3 cornerScreenSpace = Object3DControlContext.World.GetScreenSpace(cornerPosition);
|
||||
if (cornerScreenSpace.Z < bestCornerZ)
|
||||
{
|
||||
zCornerIndex = cornerIndex;
|
||||
|
|
@ -269,7 +269,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
public override void OnMouseDown(Mouse3DEventArgs mouseEvent3D)
|
||||
{
|
||||
object3DControlContext.Scene.DrawSelection = false;
|
||||
Object3DControlContext.Scene.DrawSelection = false;
|
||||
|
||||
IObject3D selectedItem = RootSelection;
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
SnappedRotationAngle = 0;
|
||||
RotatingCW = true;
|
||||
mouseMoveInfo = mouseDownInfo;
|
||||
object3DControlContext.Scene.ShowSelectionShadow = false;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = false;
|
||||
|
||||
mouseMoveInfo = new Mouse3DInfo(
|
||||
mouseEvent3D.info.HitPosition,
|
||||
|
|
@ -366,7 +366,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
{
|
||||
SnappedRotationAngle = snappingIndex * MathHelper.Tau / numSnapPoints;
|
||||
}
|
||||
else if (object3DControlContext.GuiSurface.ModifierKeys == Keys.Shift)
|
||||
else if (Object3DControlContext.GuiSurface.ModifierKeys == Keys.Shift)
|
||||
{
|
||||
snapRadians = MathHelper.DegreesToRadians(45);
|
||||
|
||||
|
|
@ -419,17 +419,17 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
|
||||
{
|
||||
object3DControlContext.Scene.DrawSelection = true;
|
||||
Object3DControlContext.Scene.DrawSelection = true;
|
||||
// if we rotated it
|
||||
if (mouseDownInfo != null)
|
||||
{
|
||||
// put in the start transform so we can go back to it if we have to
|
||||
object3DControlContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform);
|
||||
}
|
||||
|
||||
if (mouseDownInfo != null)
|
||||
{
|
||||
object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
||||
base.OnMouseUp(mouseEvent3D);
|
||||
|
|
@ -448,8 +448,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
mouseDownInfo = null;
|
||||
mouseMoveInfo = null;
|
||||
|
||||
object3DControlContext.Scene.DrawSelection = true;
|
||||
object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
Object3DControlContext.Scene.DrawSelection = true;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
||||
base.CancelOperation();
|
||||
|
|
@ -458,7 +458,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
public override void SetPosition(IObject3D selectedItem)
|
||||
{
|
||||
Vector3 boxCenter = GetControlCenter(selectedItem);
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(boxCenter);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(boxCenter);
|
||||
|
||||
GetCornerPosition(selectedItem, out int cornerIndexOut);
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
private void DrawRotationCompass(IObject3D selectedItem, DrawGlContentEventArgs drawEventArgs)
|
||||
{
|
||||
if (object3DControlContext.Scene.SelectedItem == null)
|
||||
if (Object3DControlContext.Scene.SelectedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -589,7 +589,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
var center = Vector3Ex.Transform(Vector3.Zero, rotationCenterTransform);
|
||||
if ((mouseMoveInfo.HitPosition - center).Length > rotationTransformScale * innerRadius)
|
||||
{
|
||||
object3DControlContext.World.Render3DLine(startPosition, mouseMoveInfo.HitPosition, theme.PrimaryAccentColor, drawEventArgs.ZBuffered);
|
||||
Object3DControlContext.World.Render3DLine(startPosition, mouseMoveInfo.HitPosition, theme.PrimaryAccentColor, drawEventArgs.ZBuffered);
|
||||
}
|
||||
|
||||
DrawSnappingMarks(drawEventArgs, mouseAngle, alphaValue, rotationCenterTransform, snappingMarkRadius, numSnapPoints, GetSnapIndex(selectedItem, numSnapPoints));
|
||||
|
|
@ -639,14 +639,14 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
Vector3 startPosition = Vector3Ex.Transform(unitPosition * innerRadius, rotationCenterTransform);
|
||||
Vector3 endPosition = Vector3Ex.Transform(unitPosition * outerRadius, rotationCenterTransform);
|
||||
|
||||
object3DControlContext.World.Render3DLine(startPosition, endPosition, new Color(theme.TextColor, (int)(254 * alphaValue)), drawEventArgs.ZBuffered);
|
||||
Object3DControlContext.World.Render3DLine(startPosition, endPosition, new Color(theme.TextColor, (int)(254 * alphaValue)), drawEventArgs.ZBuffered);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ForceHideAngle()
|
||||
{
|
||||
return (object3DControlContext.HoveredObject3DControl != this
|
||||
&& object3DControlContext.HoveredObject3DControl != null)
|
||||
return (Object3DControlContext.HoveredObject3DControl != this
|
||||
&& Object3DControlContext.HoveredObject3DControl != null)
|
||||
|| RootSelection != selectedItemOnMouseDown;
|
||||
}
|
||||
|
||||
|
|
@ -660,7 +660,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
private Vector3 GetControlCenter(IObject3D selectedItem)
|
||||
{
|
||||
Vector3 boxCenter = GetCornerPosition(selectedItem);
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(boxCenter);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(boxCenter);
|
||||
// figure out which way the corner is relative to the bounds
|
||||
Vector3 otherSideDelta = GetDeltaToOtherSideXy(selectedItem);
|
||||
|
||||
|
|
@ -728,7 +728,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
controlCenter = mouseDownInfo.ControlCenter;
|
||||
}
|
||||
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(rotationCenter);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(rotationCenter);
|
||||
double lengthFromCenterToControl = (rotationCenter - controlCenter).Length;
|
||||
|
||||
radius = lengthFromCenterToControl * (1 / distBetweenPixelsWorldSpace);
|
||||
|
|
@ -825,7 +825,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
var unitPosition = new Vector3(Math.Cos(mouseDownInfo.AngleOfHit), Math.Sin(mouseDownInfo.AngleOfHit), 0);
|
||||
Vector3 anglePosition = Vector3Ex.Transform(unitPosition * (radius + 100 * GuiWidget.DeviceScale), rotationCenterTransform);
|
||||
|
||||
Vector2 angleDisplayPosition = object3DControlContext.World.GetScreenPosition(anglePosition);
|
||||
Vector2 angleDisplayPosition = Object3DControlContext.World.GetScreenPosition(anglePosition);
|
||||
|
||||
var displayAngle = MathHelper.RadiansToDegrees(SnappedRotationAngle);
|
||||
if (!RotatingCW && SnappedRotationAngle > 0)
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
}
|
||||
};
|
||||
|
||||
object3DControlContext.GuiSurface.AddChild(xValueDisplayInfo);
|
||||
object3DControlContext.GuiSurface.AddChild(yValueDisplayInfo);
|
||||
Object3DControlContext.GuiSurface.AddChild(xValueDisplayInfo);
|
||||
Object3DControlContext.GuiSurface.AddChild(yValueDisplayInfo);
|
||||
|
||||
this.quadrantIndex = cornerIndex;
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
CollisionVolume = minXminYMesh.CreateBVHData();
|
||||
|
||||
object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
Object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
}
|
||||
|
||||
private void EditComplete(object s, EventArgs e)
|
||||
|
|
@ -132,7 +132,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
newSize.X = xValueDisplayInfo.Value;
|
||||
newSize.Y = yValueDisplayInfo.Value;
|
||||
|
||||
Vector3 scaleAmount = GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, object3DControlContext.GuiSurface.ModifierKeys);
|
||||
Vector3 scaleAmount = GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);
|
||||
|
||||
// scale it
|
||||
var scale = Matrix4X4.CreateScale(scaleAmount);
|
||||
|
|
@ -150,7 +150,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Invalidate();
|
||||
|
||||
object3DControlContext.Scene.AddTransformSnapshot(startingTransform);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(startingTransform);
|
||||
|
||||
transformAppliedByThis = selectedItem.Matrix;
|
||||
}
|
||||
|
|
@ -158,8 +158,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
public override void Draw(DrawGlContentEventArgs e)
|
||||
{
|
||||
bool shouldDrawScaleControls = true;
|
||||
if (object3DControlContext.SelectedObject3DControl != null
|
||||
&& object3DControlContext.SelectedObject3DControl as ScaleCornerControl == null)
|
||||
if (Object3DControlContext.SelectedObject3DControl != null
|
||||
&& Object3DControlContext.SelectedObject3DControl as ScaleCornerControl == null)
|
||||
{
|
||||
shouldDrawScaleControls = false;
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
var selectedItem = RootSelection;
|
||||
|
||||
if (selectedItem != null
|
||||
&& object3DControlContext.Scene.ShowSelectionShadow)
|
||||
&& Object3DControlContext.Scene.ShowSelectionShadow)
|
||||
{
|
||||
// Ensures that functions in this scope run against the original instance reference rather than the
|
||||
// current value, thus avoiding null reference errors that would occur otherwise
|
||||
|
|
@ -191,18 +191,18 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Vector3 endPosition = GetCornerPosition(selectedItem, (quadrantIndex + 1) % 4);
|
||||
|
||||
Frustum clippingFrustum = object3DControlContext.World.GetClippingFrustum();
|
||||
Frustum clippingFrustum = Object3DControlContext.World.GetClippingFrustum();
|
||||
|
||||
if (clippingFrustum.ClipLine(ref startPosition, ref endPosition))
|
||||
{
|
||||
if (e.ZBuffered)
|
||||
{
|
||||
object3DControlContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, theme.TextColor);
|
||||
Object3DControlContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, theme.TextColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// render on top of everything very lightly
|
||||
object3DControlContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, new Color(theme.TextColor, 20), false);
|
||||
Object3DControlContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, new Color(theme.TextColor, 20), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,10 +280,10 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Vector3 newPosition = originalPointToMove + delta;
|
||||
|
||||
if (object3DControlContext.SnapGridDistance > 0)
|
||||
if (Object3DControlContext.SnapGridDistance > 0)
|
||||
{
|
||||
// snap this position to the grid
|
||||
double snapGridDistance = object3DControlContext.SnapGridDistance;
|
||||
double snapGridDistance = Object3DControlContext.SnapGridDistance;
|
||||
|
||||
// snap this position to the grid
|
||||
newPosition.X = ((int)((newPosition.X / snapGridDistance) + .5)) * snapGridDistance;
|
||||
|
|
@ -305,7 +305,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
newSize.Y *= -1;
|
||||
}
|
||||
|
||||
Vector3 scaleAmount = GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, object3DControlContext.GuiSurface.ModifierKeys);
|
||||
Vector3 scaleAmount = GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);
|
||||
|
||||
// scale it
|
||||
var scale = Matrix4X4.CreateScale(scaleAmount);
|
||||
|
|
@ -337,7 +337,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
{
|
||||
if (HadClickOnControl)
|
||||
{
|
||||
object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
}
|
||||
|
||||
base.OnMouseUp(mouseEvent3D);
|
||||
|
|
@ -353,8 +353,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
MouseDownOnControl = false;
|
||||
MouseIsOver = false;
|
||||
|
||||
object3DControlContext.Scene.DrawSelection = true;
|
||||
object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
Object3DControlContext.Scene.DrawSelection = true;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
||||
base.CancelOperation();
|
||||
|
|
@ -363,7 +363,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
public override void SetPosition(IObject3D selectedItem)
|
||||
{
|
||||
Vector3 cornerPosition = GetCornerPosition(selectedItem, quadrantIndex);
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(cornerPosition);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(cornerPosition);
|
||||
|
||||
// figure out which way the corner is relative to the bounds
|
||||
Vector3 otherSideDelta = GetDeltaToOtherSideXy(selectedItem, quadrantIndex);
|
||||
|
|
@ -385,18 +385,18 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
lines.Clear();
|
||||
// left lines
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(xSign * DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(xSign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(xSign * DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(xSign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(yOtherSide - new Vector3(xSign * DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(yOtherSide - new Vector3(xSign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(yOtherSide - new Vector3(xSign * DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(yOtherSide - new Vector3(xSign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
|
||||
// bottom lines
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(0, ySign * DistToStart * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(0, ySign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(0, ySign * DistToStart * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(cornerPosition - new Vector3(0, ySign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0)));
|
||||
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(xOtherSide - new Vector3(0, ySign * DistToStart * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(xOtherSide - new Vector3(0, ySign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(xOtherSide - new Vector3(0, ySign * DistToStart * distBetweenPixelsWorldSpace, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(xOtherSide - new Vector3(0, ySign * (DistToStart + LineLength) * distBetweenPixelsWorldSpace, 0)));
|
||||
}
|
||||
|
||||
public static Vector3 GetScalingConsideringShiftKey(AxisAlignedBoundingBox originalSelectedBounds,
|
||||
|
|
@ -463,8 +463,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
}
|
||||
|
||||
// if another control gets a hover
|
||||
if (object3DControlContext.HoveredObject3DControl != this
|
||||
&& object3DControlContext.HoveredObject3DControl != null)
|
||||
if (Object3DControlContext.HoveredObject3DControl != this
|
||||
&& Object3DControlContext.HoveredObject3DControl != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
}
|
||||
|
||||
// if another control gets a hover
|
||||
if (object3DControlContext.HoveredObject3DControl != this
|
||||
&& object3DControlContext.HoveredObject3DControl != null)
|
||||
if (Object3DControlContext.HoveredObject3DControl != this
|
||||
&& Object3DControlContext.HoveredObject3DControl != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Vector3 newSize = Vector3.Zero;
|
||||
newSize.Z = zValueDisplayInfo.Value;
|
||||
Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, object3DControlContext.GuiSurface.ModifierKeys);
|
||||
Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);
|
||||
|
||||
Matrix4X4 scale = Matrix4X4.CreateScale(scaleAmount);
|
||||
|
||||
|
|
@ -131,10 +131,10 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Invalidate();
|
||||
|
||||
object3DControlContext.Scene.AddTransformSnapshot(startingTransform);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(startingTransform);
|
||||
};
|
||||
|
||||
object3DControlContext.GuiSurface.AddChild(zValueDisplayInfo);
|
||||
Object3DControlContext.GuiSurface.AddChild(zValueDisplayInfo);
|
||||
|
||||
DrawOnTop = true;
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
CollisionVolume = topScaleMesh.CreateBVHData();
|
||||
|
||||
object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
Object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
}
|
||||
|
||||
public override void Draw(DrawGlContentEventArgs e)
|
||||
|
|
@ -150,8 +150,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
bool shouldDrawScaleControls = true;
|
||||
var selectedItem = RootSelection;
|
||||
|
||||
if (object3DControlContext.SelectedObject3DControl != null
|
||||
&& object3DControlContext.SelectedObject3DControl as ScaleTopControl == null)
|
||||
if (Object3DControlContext.SelectedObject3DControl != null
|
||||
&& Object3DControlContext.SelectedObject3DControl as ScaleTopControl == null)
|
||||
{
|
||||
shouldDrawScaleControls = false;
|
||||
}
|
||||
|
|
@ -181,23 +181,23 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
bottomPosition.Z = originalSelectedBounds.MinXYZ.Z;
|
||||
|
||||
// render with z-buffer full black
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
Vector3 delta = topPosition - bottomPosition;
|
||||
Vector3 centerPosition = (topPosition + bottomPosition) / 2;
|
||||
Matrix4X4 rotateTransform = Matrix4X4.CreateRotation(new Quaternion(delta, Vector3.UnitX));
|
||||
Matrix4X4 scaleTransform = Matrix4X4.CreateScale((topPosition - bottomPosition).Length, distBetweenPixelsWorldSpace, distBetweenPixelsWorldSpace);
|
||||
Matrix4X4 lineTransform = scaleTransform * rotateTransform * Matrix4X4.CreateTranslation(centerPosition);
|
||||
|
||||
Frustum clippingFrustum = object3DControlContext.World.GetClippingFrustum();
|
||||
Frustum clippingFrustum = Object3DControlContext.World.GetClippingFrustum();
|
||||
|
||||
if (e.ZBuffered)
|
||||
{
|
||||
object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor);
|
||||
Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// render on top of everything very lightly
|
||||
object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, new Color(theme.TextColor, 20), false);
|
||||
Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, new Color(theme.TextColor, 20), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
public override void OnMouseDown(Mouse3DEventArgs mouseEvent3D)
|
||||
{
|
||||
if (mouseEvent3D.info != null && object3DControlContext.Scene.SelectedItem != null)
|
||||
if (mouseEvent3D.info != null && Object3DControlContext.Scene.SelectedItem != null)
|
||||
{
|
||||
hadClickOnControl = true;
|
||||
ActiveSelectedItem = RootSelection;
|
||||
|
|
@ -261,10 +261,10 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Vector3 newPosition = originalPointToMove + delta;
|
||||
|
||||
if (object3DControlContext.SnapGridDistance > 0)
|
||||
if (Object3DControlContext.SnapGridDistance > 0)
|
||||
{
|
||||
// snap this position to the grid
|
||||
double snapGridDistance = object3DControlContext.SnapGridDistance;
|
||||
double snapGridDistance = Object3DControlContext.SnapGridDistance;
|
||||
|
||||
// snap this position to the grid
|
||||
newPosition.Z = ((int)((newPosition.Z / snapGridDistance) + .5)) * snapGridDistance;
|
||||
|
|
@ -277,7 +277,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
newSize.Z = newPosition.Z - lockedBottom.Z;
|
||||
|
||||
// scale it
|
||||
Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, object3DControlContext.GuiSurface.ModifierKeys);
|
||||
Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, Object3DControlContext.GuiSurface.ModifierKeys);
|
||||
|
||||
Matrix4X4 scale = Matrix4X4.CreateScale(scaleAmount);
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
|
||||
{
|
||||
object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
base.OnMouseUp(mouseEvent3D);
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +312,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
MouseDownOnControl = false;
|
||||
MouseIsOver = false;
|
||||
|
||||
object3DControlContext.Scene.DrawSelection = true;
|
||||
object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
Object3DControlContext.Scene.DrawSelection = true;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
||||
base.CancelOperation();
|
||||
|
|
@ -325,7 +325,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
Vector3 topPosition = GetTopPosition(selectedItem);
|
||||
Vector3 bottomPosition = new Vector3(topPosition.X, topPosition.Y, selectedBounds.MinXYZ.Z);
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
|
||||
Vector3 arrowCenter = topPosition;
|
||||
arrowCenter.Z += arrowSize / 2 * distBetweenPixelsWorldSpace;
|
||||
|
|
@ -336,10 +336,10 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
lines.Clear();
|
||||
// left lines
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(topPosition + new Vector3(DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(topPosition + new Vector3(DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(new Vector2(lines[0].X + LineLength, lines[0].Y));
|
||||
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(bottomPosition + new Vector3(DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(bottomPosition + new Vector3(DistToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(new Vector2(lines[2].X + LineLength, lines[2].Y));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,9 +131,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
}
|
||||
|
||||
public static IPrimitive CreateTraceData(FaceList faceList, List<Vector3Float> vertexList, int maxRecursion = int.MaxValue)
|
||||
public static ITraceable CreateTraceData(FaceList faceList, List<Vector3Float> vertexList, int maxRecursion = int.MaxValue)
|
||||
{
|
||||
var allPolys = new List<IPrimitive>();
|
||||
var allPolys = new List<ITraceable>();
|
||||
|
||||
foreach (var face in faceList)
|
||||
{
|
||||
|
|
@ -468,7 +468,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return supportColumnData;
|
||||
}
|
||||
|
||||
private IPrimitive GetTraceData(IEnumerable<IObject3D> supportCandidates)
|
||||
private ITraceable GetTraceData(IEnumerable<IObject3D> supportCandidates)
|
||||
{
|
||||
List<Vector3Float> supportVerts;
|
||||
FaceList supportFaces;
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
if (items.Any())
|
||||
{
|
||||
int i = 0;
|
||||
foreach(var p in items)
|
||||
foreach (var (BvhItem, Matrix) in items)
|
||||
{
|
||||
Object3DControlLayer.RenderBounds(e, world, p.Matrix, p.BvhItem, i++);
|
||||
Object3DControlLayer.RenderBounds(e, world, Matrix, BvhItem, i++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public static class PrimitivesExtensions
|
||||
{
|
||||
public static IEnumerable<(IBvhItem BvhItem, Matrix4X4 Matrix)> FilterX(this IPrimitive source, Predicate<BvhItemView> filter)
|
||||
public static IEnumerable<(IBvhItem BvhItem, Matrix4X4 Matrix)> FilterX(this ITraceable source, Predicate<BvhItemView> filter)
|
||||
{
|
||||
var items = new Stack<(IBvhItem BvhItem, Matrix4X4 Matrix)>();
|
||||
items.Push((source, Matrix4X4.Identity));
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
|
||||
// if another control gets a hover
|
||||
if (object3DControlContext.HoveredObject3DControl != this
|
||||
&& object3DControlContext.HoveredObject3DControl != null)
|
||||
if (Object3DControlContext.HoveredObject3DControl != this
|
||||
&& Object3DControlContext.HoveredObject3DControl != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -112,10 +112,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
var newZPosition = zHeightDisplayInfo.Value;
|
||||
|
||||
if (object3DControlContext.SnapGridDistance > 0)
|
||||
if (Object3DControlContext.SnapGridDistance > 0)
|
||||
{
|
||||
// snap this position to the grid
|
||||
double snapGridDistance = object3DControlContext.SnapGridDistance;
|
||||
double snapGridDistance = Object3DControlContext.SnapGridDistance;
|
||||
|
||||
// snap this position to the grid
|
||||
newZPosition = ((int)((newZPosition / snapGridDistance) + .5)) * snapGridDistance;
|
||||
|
|
@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
context.Scene.AddTransformSnapshot(startingTransform);
|
||||
};
|
||||
|
||||
object3DControlContext.GuiSurface.AddChild(zHeightDisplayInfo);
|
||||
Object3DControlContext.GuiSurface.AddChild(zHeightDisplayInfo);
|
||||
|
||||
DrawOnTop = true;
|
||||
|
||||
|
|
@ -144,14 +144,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
CollisionVolume = upArrowMesh.CreateBVHData();
|
||||
|
||||
object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
Object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
}
|
||||
|
||||
public override void Draw(DrawGlContentEventArgs e)
|
||||
{
|
||||
bool shouldDrawMoveControls = true;
|
||||
if (object3DControlContext.SelectedObject3DControl != null
|
||||
&& object3DControlContext.SelectedObject3DControl as MoveInZControl == null)
|
||||
if (Object3DControlContext.SelectedObject3DControl != null
|
||||
&& Object3DControlContext.SelectedObject3DControl as MoveInZControl == null)
|
||||
{
|
||||
shouldDrawMoveControls = false;
|
||||
}
|
||||
|
|
@ -234,10 +234,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
double newZPosition = mouseDownSelectedBounds.MinXYZ.Z + delta;
|
||||
|
||||
if (object3DControlContext.SnapGridDistance > 0)
|
||||
if (Object3DControlContext.SnapGridDistance > 0)
|
||||
{
|
||||
// snap this position to the grid
|
||||
double snapGridDistance = object3DControlContext.SnapGridDistance;
|
||||
double snapGridDistance = Object3DControlContext.SnapGridDistance;
|
||||
|
||||
// snap this position to the grid
|
||||
newZPosition = ((int)((newZPosition / snapGridDistance) + .5)) * snapGridDistance;
|
||||
|
|
@ -259,7 +259,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public override void OnMouseUp(Mouse3DEventArgs mouseEvent3D)
|
||||
{
|
||||
object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
Object3DControlContext.Scene.AddTransformSnapshot(transformOnMouseDown);
|
||||
base.OnMouseUp(mouseEvent3D);
|
||||
}
|
||||
|
||||
|
|
@ -273,8 +273,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
MouseDownOnControl = false;
|
||||
MouseIsOver = false;
|
||||
|
||||
object3DControlContext.Scene.DrawSelection = true;
|
||||
object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
Object3DControlContext.Scene.DrawSelection = true;
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
||||
base.CancelOperation();
|
||||
|
|
@ -286,7 +286,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
Vector3 topPosition = GetTopPosition(selectedItem);
|
||||
var bottomPosition = new Vector3(topPosition.X, topPosition.Y, selectedBounds.MinXYZ.Z);
|
||||
double distBetweenPixelsWorldSpace = object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
double distBetweenPixelsWorldSpace = Object3DControlContext.World.GetWorldUnitsPerScreenPixelAtPosition(topPosition);
|
||||
|
||||
Vector3 boxCenter = topPosition;
|
||||
boxCenter.Z += (10 * GuiWidget.DeviceScale + upArrowSize / 2) * distBetweenPixelsWorldSpace;
|
||||
|
|
@ -298,10 +298,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// left lines
|
||||
// the lines on the bed
|
||||
var bedPosition = new Vector3(topPosition.X, topPosition.Y, 0);
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(bedPosition + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(bedPosition + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(new Vector2(lines[0].X + lineLength, lines[0].Y));
|
||||
|
||||
lines.Add(object3DControlContext.World.GetScreenPosition(bottomPosition + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(Object3DControlContext.World.GetScreenPosition(bottomPosition + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0)));
|
||||
lines.Add(new Vector2(lines[2].X + lineLength, lines[2].Y));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
var selectedItem = RootSelection;
|
||||
if (selectedItem != null
|
||||
&& object3DControlContext.Scene.ShowSelectionShadow)
|
||||
&& Object3DControlContext.Scene.ShowSelectionShadow)
|
||||
{
|
||||
// draw the bounds on the bed
|
||||
AxisAlignedBoundingBox selectedBounds = selectedItem.GetAxisAlignedBoundingBox();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.DrawOnTop = true;
|
||||
this.meshSelectInfo = currentSelectInfo;
|
||||
object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
Object3DControlContext.GuiSurface.AfterDraw += Object3DControl_AfterDraw;
|
||||
}
|
||||
|
||||
public override void SetPosition(IObject3D selectedItem)
|
||||
|
|
@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// draw the hight from the bottom to the bed
|
||||
AxisAlignedBoundingBox selectedBounds = selectedItem.GetAxisAlignedBoundingBox();
|
||||
|
||||
var world = object3DControlContext.World;
|
||||
var world = Object3DControlContext.World;
|
||||
|
||||
switch (meshSelectInfo.HitQuadrant)
|
||||
{
|
||||
|
|
@ -116,8 +116,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private void Object3DControl_AfterDraw(object drawingWidget, DrawEventArgs drawEvent)
|
||||
{
|
||||
if (object3DControlContext.Scene.SelectedItem != null
|
||||
&& object3DControlContext.SnapGridDistance > 0
|
||||
if (Object3DControlContext.Scene.SelectedItem != null
|
||||
&& Object3DControlContext.SnapGridDistance > 0
|
||||
&& meshSelectInfo.DownOnPart)
|
||||
{
|
||||
if (drawEvent != null)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.RayTracer;
|
||||
|
||||
namespace MatterHackers.MeshVisualizer
|
||||
{
|
||||
|
|
@ -56,5 +57,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
bool DrawOnTop { get; }
|
||||
|
||||
void Draw(DrawGlContentEventArgs e);
|
||||
|
||||
ITraceable GetTraceable();
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.RayTracer;
|
||||
using MatterHackers.RayTracer.Traceable;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MeshVisualizer
|
||||
|
|
@ -42,10 +43,10 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public Object3DControlBase(IObject3DControlContext meshViewerToDrawWith)
|
||||
{
|
||||
this.object3DControlContext = meshViewerToDrawWith;
|
||||
this.Object3DControlContext = meshViewerToDrawWith;
|
||||
}
|
||||
|
||||
public IPrimitive CollisionVolume { get; set; }
|
||||
public ITraceable CollisionVolume { get; set; }
|
||||
|
||||
public bool DrawOnTop { get; protected set; }
|
||||
|
||||
|
|
@ -70,14 +71,14 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public string Name { get; set; }
|
||||
|
||||
protected IObject3DControlContext object3DControlContext { get; }
|
||||
protected IObject3DControlContext Object3DControlContext { get; }
|
||||
|
||||
public IObject3D RootSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
var selectedItemRoot = object3DControlContext.Scene.SelectedItemRoot;
|
||||
var selectedItem = object3DControlContext.Scene.SelectedItem;
|
||||
var selectedItemRoot = Object3DControlContext.Scene.SelectedItemRoot;
|
||||
var selectedItem = Object3DControlContext.Scene.SelectedItem;
|
||||
return (selectedItemRoot == selectedItem) ? selectedItem : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +106,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public void Invalidate()
|
||||
{
|
||||
object3DControlContext.GuiSurface.Invalidate();
|
||||
Object3DControlContext.GuiSurface.Invalidate();
|
||||
}
|
||||
|
||||
public virtual void CancelOperation()
|
||||
|
|
@ -121,7 +122,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
if (mouseEvent3D.MouseEvent2D.Button == MouseButtons.Left)
|
||||
{
|
||||
MouseDownOnControl = true;
|
||||
object3DControlContext.GuiSurface.Invalidate();
|
||||
Object3DControlContext.GuiSurface.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,5 +138,16 @@ namespace MatterHackers.MeshVisualizer
|
|||
public virtual void SetPosition(IObject3D selectedItem)
|
||||
{
|
||||
}
|
||||
|
||||
public ITraceable GetTraceable()
|
||||
{
|
||||
if (CollisionVolume != null)
|
||||
{
|
||||
ITraceable traceData = CollisionVolume;
|
||||
return new Transform(traceData, TotalTransform);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
Ray ray = this.World.GetRayForLocalBounds(mouseEvent.Position);
|
||||
if (this.Scene.SelectedItem != null
|
||||
&& !SuppressUiVolumes
|
||||
&& !SuppressObject3DControls
|
||||
&& FindHitObject3DControl(ray, out mouseDownObject3DControl, out IntersectInfo info))
|
||||
{
|
||||
mouseDownObject3DControl.OnMouseDown(new Mouse3DEventArgs(mouseEvent, ray, info));
|
||||
|
|
@ -276,7 +276,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
base.OnMouseMove(mouseEvent);
|
||||
|
||||
if (SuppressUiVolumes
|
||||
if (SuppressObject3DControls
|
||||
|| !this.PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y))
|
||||
{
|
||||
return;
|
||||
|
|
@ -320,7 +320,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
Invalidate();
|
||||
|
||||
if (SuppressUiVolumes)
|
||||
if (SuppressObject3DControls)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -407,28 +407,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: Rewrite as projection without extra list
|
||||
// - Looks like the extra list is always required as CreateNewHierachy requires a List and we can only produce an IEnumerable without the list overhead
|
||||
// - var uiTraceables = iaVolumes.Where(ia => ia.CollisionVolume != null).Select(ia => new Transform(ia.CollisionVolume, ia.TotalTransform)).ToList<IPrimitive>();
|
||||
var uiTraceables = new List<IPrimitive>();
|
||||
foreach (var object3DControl in object3DControls.OfType<Object3DControlBase>())
|
||||
var traceables = new List<ITraceable>();
|
||||
foreach (var object3DControl in object3DControls)
|
||||
{
|
||||
if (object3DControl.CollisionVolume != null)
|
||||
ITraceable traceable = object3DControl.GetTraceable();
|
||||
if (traceable != null)
|
||||
{
|
||||
IPrimitive traceData = object3DControl.CollisionVolume;
|
||||
uiTraceables.Add(new Transform(traceData, object3DControl.TotalTransform));
|
||||
traceables.Add(traceable);
|
||||
}
|
||||
}
|
||||
|
||||
if (uiTraceables.Count <= 0)
|
||||
if (traceables.Count <= 0)
|
||||
{
|
||||
info = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
IPrimitive allUiObjects = BoundingVolumeHierarchy.CreateNewHierachy(uiTraceables);
|
||||
var bvhHierachy = BoundingVolumeHierarchy.CreateNewHierachy(traceables);
|
||||
|
||||
info = allUiObjects.GetClosestIntersection(ray);
|
||||
info = bvhHierachy.GetClosestIntersection(ray);
|
||||
if (info != null)
|
||||
{
|
||||
foreach (var object3DControlBase in object3DControls.OfType<Object3DControlBase>())
|
||||
|
|
@ -449,7 +446,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool SuppressUiVolumes { get; set; } = false;
|
||||
public bool SuppressObject3DControls { get; set; } = false;
|
||||
|
||||
public bool MouseDownOnObject3DControlVolume => SelectedObject3DControl != null;
|
||||
|
||||
|
|
|
|||
|
|
@ -614,10 +614,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
foreach (var item in this.Object3DControls.OfType<IObject3DControl>())
|
||||
{
|
||||
item.Visible = !SuppressUiVolumes;
|
||||
item.Visible = !SuppressObject3DControls;
|
||||
}
|
||||
|
||||
if (SuppressUiVolumes)
|
||||
if (SuppressObject3DControls)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public class TumbleCubeControl : GuiWidget
|
||||
{
|
||||
private Mesh cube = PlatonicSolids.CreateCube(4, 4, 4);
|
||||
private IPrimitive cubeTraceData;
|
||||
private ITraceable cubeTraceData;
|
||||
private Object3DControlLayer object3DControlLayer;
|
||||
private Vector2 lastMovePosition;
|
||||
private LightingData lighting = new LightingData();
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
if (mouseEvent.Button == MouseButtons.Right ||
|
||||
mouseEvent.Button == MouseButtons.Middle)
|
||||
{
|
||||
this.Object3DControlLayer.SuppressUiVolumes = true;
|
||||
this.Object3DControlLayer.SuppressObject3DControls = true;
|
||||
}
|
||||
|
||||
base.OnMouseDown(mouseEvent);
|
||||
|
|
@ -1067,7 +1067,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (!this.Object3DControlLayer.MouseDownOnObject3DControlVolume)
|
||||
{
|
||||
this.Object3DControlLayer.SuppressUiVolumes = true;
|
||||
this.Object3DControlLayer.SuppressObject3DControls = true;
|
||||
|
||||
var info = new IntersectInfo();
|
||||
|
||||
|
|
@ -1429,7 +1429,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
this.Object3DControlLayer.SuppressUiVolumes = false;
|
||||
this.Object3DControlLayer.SuppressObject3DControls = false;
|
||||
|
||||
CurrentSelectInfo.DownOnPart = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue