Vixen
02b45cc4
csharp
public sealed class TransformGizmo

The handles that move, turn and resize what is selected.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Every drag is recomputed from where it started, never accumulated. The gizmo records what each target held on mouse-down and applies the whole of the drag to that, which is what makes snapping land on the grid rather than near it, makes a drag that goes out and comes back end where it began, and makes floating-point drift impossible instead of merely small. An implementation that adds each frame's delta to the current value has all three bugs and none of them are reproducible.

It is arithmetic over an interface, with no renderer in it. What the handles look like belongs to the viewport; where they are, what is under the pointer and what a drag means are here, so all of it is testable with no device.

⚠ The handles are a constant size on screen. A gizmo in world units is a dot at forty metres and fills the viewport at half a metre. Everything below that is measured in world units is scaled by WorldPerPixel, which is the one place the camera's distance enters the arithmetic.

Fields and properties (26)

  • public float HandleLength

    How long an arm is, in render pixels.

  • public float GrabRadius

    How near the pointer has to be to an arm to grab it, in render pixels.

  • public float Thickness

    How thick the handles are drawn, in render pixels.

  • public float PlaneOffset

    How far along the arms the plane quads sit, as a fraction of the arm.

  • public float PlaneSize

    How big the plane quads are, as a fraction of the arm.

  • public float CentreRadius

    How big the middle box is, in render pixels.

  • public float ScreenRingScale

    How far out the screen-facing rotation ring sits, as a fraction of the arm.

  • public float HeadLength

    How long an arm's head is, as a fraction of the arm.

  • public float HeadRadius

    How wide an arm's head is, as a fraction of the arm.

  • public float ArmStart

    How far along an arm its grabbable part starts, as a fraction of the arm.

  • public float MinimumAxisLength

    How short an arm may look before it stops being offered, in render pixels.

  • public float EdgeOnLimit

    How nearly a rotation ring may be edge-on before its drag is measured along the screen instead of in its own plane, as the cosine of the angle to the view direction.

  • public GizmoMode Mode

    What the gizmo changes.

  • public GizmoSpace Space

    Which axes the handles point along.

  • public PivotMode Pivot

    Where the handles sit when several things are selected.

  • public SnapContext Snap

    What a drag rounds to.

  • public GizmoHandle Hovered

    The handle the pointer is over, if any.

  • public GizmoHandle Active

    The handle being dragged, if any.

  • public bool IsDragging

    Whether a drag is under way.

  • public IReadOnlyList<IGizmoTarget> Targets

    What the gizmo is moving, in selection order.

  • public float Tolerance

    How near the pointer has to be to a handle to grab it, in render pixels.

  • public Vector3 Origin

    Where the handles sit, in world space.

  • public SnapHit? SnapTo

    Where a translate drag has been told to put the gizmo's origin, instead of where the pointer says.

  • public Vector3 SnapOrigin

    Which point of what is being dragged a snap puts on the target.

  • public TypedTransform? Typed

    An exact transform typed during the drag, instead of the one the pointer says.

  • public (GizmoMode Kind, Vector3 Offset, float Scalar) Dragged

    What the drag has done so far, for a readout to show.

Methods (10)

  • public void Attach(IEnumerable<IGizmoTarget> selection)

    Points the gizmo at a selection.

  • public Matrix4x4 Basis(EditorCamera camera)

    Which way the arms point.

  • public float WorldPerPixel(EditorCamera camera, int height)

    How many world units one render pixel is, at the gizmo's origin.

  • public bool IsAxisVisible(Vector3 axis, EditorCamera camera)

    Whether an arm along a direction is long enough on screen to be worth offering.

  • public GizmoHandle HitTest(Vector2 point, EditorCamera camera, int width, int height)

    Which handle is under a point.

  • public bool Begin(GizmoHandle handle, Ray ray, EditorCamera camera)

    Starts a drag.

  • public bool Drag(Ray ray, EditorCamera camera)

    Applies the whole of the drag so far.

  • public void End()

    Ends the drag, leaving everything where it is.

  • public bool Cancel()

    Ends the drag and puts everything back where it started.

  • public IReadOnlyList<(Vector3 Position, Quaternion Rotation, Vector3 Scale)> Captured()

    What each target held when the drag began, for the undo command.

Used by (16)

  • EditorAffordanceTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • GizmoGeometryVixen.Editor.SceneView
  • GizmoGeometryTestsVixen.Editor.SceneView.Tests
  • GizmoTestsVixen.Editor.SceneView.Tests
  • ManipulationTestsVixen.Editor.SceneView.Tests
  • OneEditPathTestsVixen.Editor.App.Tests
  • PrecisionTestsVixen.Editor.SceneView.Tests
  • ProxyShapeEditorTestsVixen.Editor.AssetEditors.Tests
  • SceneViewportVixen.Editor.SceneView
  • SnapCommandTestsVixen.Editor.App.Tests
  • SnapContextTestsVixen.Editor.SceneView.Tests
  • SnapTestsVixen.Editor.SceneView.Tests
  • ViewportChromeVixen.Editor.App
  • ViewportInputTestsVixen.Editor.SceneView.Tests
  • WorkPlaneCommandTestsVixen.Editor.App.Tests