Improving 3D control rendering

Width Depth control able to alter part
This commit is contained in:
Lars Brubaker 2021-04-12 18:00:59 -07:00
parent 9a00aa4e87
commit d5ca11dcd4
8 changed files with 18 additions and 19 deletions

View file

@ -39,6 +39,8 @@ namespace MatterHackers.MatterControl.DesignTools
/// <summary>
/// Gets the alpha of the non z-buffered lines in the editor
/// </summary>
public static int LineAlpha => 30;
public static int LineAlpha => 80;
public static int Controls3DAlpha => 80;
}
}

View file

@ -180,7 +180,7 @@ namespace MatterHackers.Plugins.EditorTools
if (shouldDrawScaleControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(topScaleMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
}
@ -323,8 +323,6 @@ namespace MatterHackers.Plugins.EditorTools
selectedItem.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues));
}
var startMatrix = selectedItem.Matrix;
selectedItem.Matrix = startMatrix;
await selectedItem.Rebuild();

View file

@ -176,7 +176,7 @@ namespace MatterHackers.Plugins.EditorTools
if (shouldDrawScaleControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
}

View file

@ -177,8 +177,7 @@ namespace MatterHackers.Plugins.EditorTools
var selectedItem = RootSelection;
if (selectedItem != null
&& Object3DControlContext.Scene.ShowSelectionShadow)
if (selectedItem != null)
{
// 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
@ -186,7 +185,7 @@ namespace MatterHackers.Plugins.EditorTools
if (shouldDrawScaleControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
}
@ -459,7 +458,6 @@ namespace MatterHackers.Plugins.EditorTools
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)));
}
}
}

View file

@ -160,7 +160,7 @@ namespace MatterHackers.Plugins.EditorTools
if (shouldDrawScaleControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(topScaleMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
}

View file

@ -45,7 +45,7 @@ using System.Collections.Generic;
namespace MatterHackers.Plugins.EditorTools
{
public class ScaleEdgeControl : Object3DControl
public class ScaleWidthDepthControl : Object3DControl
{
/// <summary>
/// Edge starting from the back (+y) going ccw
@ -76,7 +76,7 @@ namespace MatterHackers.Plugins.EditorTools
private Vector2 sizeOnMouseDown;
public ScaleEdgeControl(IObject3DControlContext context, int edgeIndex)
public ScaleWidthDepthControl(IObject3DControlContext context, int edgeIndex)
: base(context)
{
theme = MatterControl.AppContext.Theme;
@ -232,8 +232,7 @@ namespace MatterHackers.Plugins.EditorTools
var selectedItem = RootSelection;
if (selectedItem != null
&& Object3DControlContext.Scene.ShowSelectionShadow)
if (selectedItem != null)
{
// 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
@ -241,7 +240,7 @@ namespace MatterHackers.Plugins.EditorTools
if (shouldDrawScaleControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
}
@ -317,7 +316,7 @@ namespace MatterHackers.Plugins.EditorTools
base.OnMouseDown(mouseEvent3D);
}
public override void OnMouseMove(Mouse3DEventArgs mouseEvent3D, bool mouseIsOver)
public override async void OnMouseMove(Mouse3DEventArgs mouseEvent3D, bool mouseIsOver)
{
var selectedItem = RootSelection;
ActiveSelectedItem = selectedItem;
@ -387,6 +386,8 @@ namespace MatterHackers.Plugins.EditorTools
widthDepthItem.Depth *= scaleAmount.Y;
}
await selectedItem.Rebuild();
// and keep the locked edge in place
Vector3 newLockedEdge = GetEdgePosition(selectedItem, (edgeIndex + 2) % 4);

View file

@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (shouldDrawMoveControls)
{
// don't draw if any other control is dragging
if (MouseIsOver)
if (MouseIsOver || MouseDownOnControl)
{
GLHelper.Render(upArrowMesh, theme.PrimaryAccentColor, TotalTransform, RenderTypes.Shaded);
}

View file

@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (selectedItem is IObjectWithWidthAndDepth widthAndDepth)
{
#if DEBUG
Object3DControls.Add(new ScaleEdgeControl(this, 0));
Object3DControls.Add(new ScaleWidthDepthControl(this, 0));
#else
AddControls(ControlTypes.ScaleMatrixXY);
#endif
@ -1122,7 +1122,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
if (object3DControl.DrawOnTop)
{
object3DControl.Draw(new DrawGlContentEventArgs(false, 60, e));
object3DControl.Draw(new DrawGlContentEventArgs(false, Constants.Controls3DAlpha, e));
}
}