Getting the snap grid to work in x and y.
This commit is contained in:
parent
cfddadb144
commit
a865ff8c77
3 changed files with 62 additions and 7 deletions
|
|
@ -67,10 +67,37 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();
|
||||
|
||||
Mesh bottomBounds = PlatonicSolids.CreateCube(selectedBounds.XSize, selectedBounds.YSize, .1);
|
||||
Vector3 bottomRight = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.maxXYZ.y, selectedBounds.minXYZ.z);
|
||||
Vector2 bottomRightScreenPosition = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(bottomRight);
|
||||
|
||||
RenderMeshToGl.Render(bottomBounds, new RGBA_Bytes(22, 80, 220, 30), TotalTransform, RenderTypes.Shaded);
|
||||
|
||||
if (false)
|
||||
{
|
||||
Vector3 lastHitPosition = view3DWidget.LastHitPosition;
|
||||
double lineWidth = .5;
|
||||
if (lastHitPosition.x < selectedBounds.Center.x)
|
||||
{
|
||||
Mesh leftSide = PlatonicSolids.CreateCube(lineWidth, selectedBounds.YSize, .1);
|
||||
Matrix4X4 leftTransform = Matrix4X4.CreateTranslation(new Vector3(selectedBounds.minXYZ.x, selectedBounds.Center.y, 0.1));
|
||||
RenderMeshToGl.Render(leftSide, new RGBA_Bytes(222, 80, 20), leftTransform, RenderTypes.Shaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mesh rightSide = PlatonicSolids.CreateCube(lineWidth, selectedBounds.YSize, .1);
|
||||
Matrix4X4 rightTransform = Matrix4X4.CreateTranslation(new Vector3(selectedBounds.maxXYZ.x, selectedBounds.Center.y, 0.1));
|
||||
RenderMeshToGl.Render(rightSide, new RGBA_Bytes(222, 80, 20), rightTransform, RenderTypes.Shaded);
|
||||
}
|
||||
if (lastHitPosition.y < selectedBounds.Center.y)
|
||||
{
|
||||
Mesh bottomSide = PlatonicSolids.CreateCube(selectedBounds.XSize, lineWidth, .1);
|
||||
Matrix4X4 bottomTransform = Matrix4X4.CreateTranslation(new Vector3(selectedBounds.Center.x, selectedBounds.minXYZ.y, 0.1));
|
||||
RenderMeshToGl.Render(bottomSide, new RGBA_Bytes(222, 80, 20), bottomTransform, RenderTypes.Shaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mesh topSide = PlatonicSolids.CreateCube(selectedBounds.XSize, lineWidth, .1);
|
||||
Matrix4X4 topTransform = Matrix4X4.CreateTranslation(new Vector3(selectedBounds.Center.x, selectedBounds.maxXYZ.y, 0.1));
|
||||
RenderMeshToGl.Render(topSide, new RGBA_Bytes(222, 80, 20), topTransform, RenderTypes.Shaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.DrawGlContent(e);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
// move it back to where it started
|
||||
ScaleRotateTranslate translated = MeshViewerToDrawWith.SelectedMeshGroupTransform;
|
||||
translated.translation *= Matrix4X4.CreateTranslation(new Vector3(-lastMoveDelta)); ;
|
||||
translated.translation *= Matrix4X4.CreateTranslation(new Vector3(-lastMoveDelta));
|
||||
MeshViewerToDrawWith.SelectedMeshGroupTransform = translated;
|
||||
|
||||
if(MeshViewerToDrawWith.SnapGridDistance > 0)
|
||||
|
|
@ -110,14 +110,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// snap this position to the grid
|
||||
double snapGridDistance = MeshViewerToDrawWith.SnapGridDistance;
|
||||
AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();
|
||||
double bottom = selectedBounds.minXYZ.z + delta.z;
|
||||
|
||||
// snap the z position
|
||||
double bottom = selectedBounds.minXYZ.z + delta.z;
|
||||
double snappedBottom = ((int)((bottom / snapGridDistance) + .5)) * snapGridDistance;
|
||||
delta.z = snappedBottom - selectedBounds.minXYZ.z;
|
||||
}
|
||||
|
||||
// and move it from there to where we are now
|
||||
translated.translation *= Matrix4X4.CreateTranslation(new Vector3(delta));
|
||||
// and move it from there to where we are now
|
||||
translated.translation *= Matrix4X4.CreateTranslation(new Vector3(delta));
|
||||
MeshViewerToDrawWith.SelectedMeshGroupTransform = translated;
|
||||
|
||||
lastMoveDelta = delta;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue