Improving 3D control rendering
Width Depth control able to alter part
This commit is contained in:
parent
9a00aa4e87
commit
d5ca11dcd4
8 changed files with 18 additions and 19 deletions
|
|
@ -39,6 +39,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the alpha of the non z-buffered lines in the editor
|
/// Gets the alpha of the non z-buffered lines in the editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int LineAlpha => 30;
|
public static int LineAlpha => 80;
|
||||||
|
|
||||||
|
public static int Controls3DAlpha => 80;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +180,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
if (shouldDrawScaleControls)
|
if (shouldDrawScaleControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// 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);
|
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));
|
selectedItem.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
var startMatrix = selectedItem.Matrix;
|
|
||||||
selectedItem.Matrix = startMatrix;
|
|
||||||
|
|
||||||
await selectedItem.Rebuild();
|
await selectedItem.Rebuild();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
if (shouldDrawScaleControls)
|
if (shouldDrawScaleControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// 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);
|
GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
|
|
||||||
var selectedItem = RootSelection;
|
var selectedItem = RootSelection;
|
||||||
|
|
||||||
if (selectedItem != null
|
if (selectedItem != null)
|
||||||
&& Object3DControlContext.Scene.ShowSelectionShadow)
|
|
||||||
{
|
{
|
||||||
// Ensures that functions in this scope run against the original instance reference rather than the
|
// 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
|
// current value, thus avoiding null reference errors that would occur otherwise
|
||||||
|
|
@ -186,7 +185,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
if (shouldDrawScaleControls)
|
if (shouldDrawScaleControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// 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);
|
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 * 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 + LineLength) * distBetweenPixelsWorldSpace, 0)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
if (shouldDrawScaleControls)
|
if (shouldDrawScaleControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// 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);
|
GLHelper.Render(topScaleMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MatterHackers.Plugins.EditorTools
|
namespace MatterHackers.Plugins.EditorTools
|
||||||
{
|
{
|
||||||
public class ScaleEdgeControl : Object3DControl
|
public class ScaleWidthDepthControl : Object3DControl
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Edge starting from the back (+y) going ccw
|
/// Edge starting from the back (+y) going ccw
|
||||||
|
|
@ -76,7 +76,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
|
|
||||||
private Vector2 sizeOnMouseDown;
|
private Vector2 sizeOnMouseDown;
|
||||||
|
|
||||||
public ScaleEdgeControl(IObject3DControlContext context, int edgeIndex)
|
public ScaleWidthDepthControl(IObject3DControlContext context, int edgeIndex)
|
||||||
: base(context)
|
: base(context)
|
||||||
{
|
{
|
||||||
theme = MatterControl.AppContext.Theme;
|
theme = MatterControl.AppContext.Theme;
|
||||||
|
|
@ -232,8 +232,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
|
|
||||||
var selectedItem = RootSelection;
|
var selectedItem = RootSelection;
|
||||||
|
|
||||||
if (selectedItem != null
|
if (selectedItem != null)
|
||||||
&& Object3DControlContext.Scene.ShowSelectionShadow)
|
|
||||||
{
|
{
|
||||||
// Ensures that functions in this scope run against the original instance reference rather than the
|
// 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
|
// current value, thus avoiding null reference errors that would occur otherwise
|
||||||
|
|
@ -241,7 +240,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
if (shouldDrawScaleControls)
|
if (shouldDrawScaleControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// 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);
|
GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded);
|
||||||
}
|
}
|
||||||
|
|
@ -317,7 +316,7 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
base.OnMouseDown(mouseEvent3D);
|
base.OnMouseDown(mouseEvent3D);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMouseMove(Mouse3DEventArgs mouseEvent3D, bool mouseIsOver)
|
public override async void OnMouseMove(Mouse3DEventArgs mouseEvent3D, bool mouseIsOver)
|
||||||
{
|
{
|
||||||
var selectedItem = RootSelection;
|
var selectedItem = RootSelection;
|
||||||
ActiveSelectedItem = selectedItem;
|
ActiveSelectedItem = selectedItem;
|
||||||
|
|
@ -387,6 +386,8 @@ namespace MatterHackers.Plugins.EditorTools
|
||||||
widthDepthItem.Depth *= scaleAmount.Y;
|
widthDepthItem.Depth *= scaleAmount.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await selectedItem.Rebuild();
|
||||||
|
|
||||||
// and keep the locked edge in place
|
// and keep the locked edge in place
|
||||||
Vector3 newLockedEdge = GetEdgePosition(selectedItem, (edgeIndex + 2) % 4);
|
Vector3 newLockedEdge = GetEdgePosition(selectedItem, (edgeIndex + 2) % 4);
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
if (shouldDrawMoveControls)
|
if (shouldDrawMoveControls)
|
||||||
{
|
{
|
||||||
// don't draw if any other control is dragging
|
// don't draw if any other control is dragging
|
||||||
if (MouseIsOver)
|
if (MouseIsOver || MouseDownOnControl)
|
||||||
{
|
{
|
||||||
GLHelper.Render(upArrowMesh, theme.PrimaryAccentColor, TotalTransform, RenderTypes.Shaded);
|
GLHelper.Render(upArrowMesh, theme.PrimaryAccentColor, TotalTransform, RenderTypes.Shaded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
if (selectedItem is IObjectWithWidthAndDepth widthAndDepth)
|
if (selectedItem is IObjectWithWidthAndDepth widthAndDepth)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Object3DControls.Add(new ScaleEdgeControl(this, 0));
|
Object3DControls.Add(new ScaleWidthDepthControl(this, 0));
|
||||||
#else
|
#else
|
||||||
AddControls(ControlTypes.ScaleMatrixXY);
|
AddControls(ControlTypes.ScaleMatrixXY);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1122,7 +1122,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
{
|
{
|
||||||
if (object3DControl.DrawOnTop)
|
if (object3DControl.DrawOnTop)
|
||||||
{
|
{
|
||||||
object3DControl.Draw(new DrawGlContentEventArgs(false, 60, e));
|
object3DControl.Draw(new DrawGlContentEventArgs(false, Constants.Controls3DAlpha, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue