public sealed class SnapContextWhat every transform in the editor rounds to, as one thing they all consult.
Remarks
Doc 24's D4, and it is a context rather than a settings bag for one reason. Snapping attached to the gizmo is a vertex snap that works when you drag an object and not when you extrude a face, which reads as the feature being broken rather than as two features. TransformGizmo, ScenePlacement and every blockout tool take the same instance, so there is one answer to "am I snapping" and one place it is written.
Three orthogonal parts, which is Blender's arrangement and the reason its snapping is the one people miss: Elements is what you land on, Base is what of yours lands on it, and Modifiers is everything that is true of a snap without being either.
⚠ The four booleans and three steps that were here before are still here, and still mean what they meant. They are views over Elements rather than separate state — two writers for one fact is how a toolbar toggle and a settings panel end up disagreeing — so everything that reads SnapPosition or SnapToVertex is unchanged, and everything that writes them moves the set.
Snapping rounds the total of a drag, not each step of it. Rounding each frame's delta accumulates the rounding error, so a slow drag across ten grid squares lands somewhere between two of them and a fast one lands on a line. Every implementation gets this wrong once.
The steps are separate numbers because they are separate decisions: a level built on a quarter-metre grid still wants fifteen-degree rotations.
Fields and properties (15)
public SnapElements ElementsWhat a position may land on.
public SnapBase BaseWhich part of what is being dragged is put on it.
public SnapModifiers ModifiersThe orthogonal switches.
public bool SnapPositionWhether a translate moves by whole steps of GridStep.
public bool AbsoluteGridWhether a translate lands on the world grid rather than moving by whole steps of it.
public bool SnapToVertexWhether a drag lands on the nearest vertex of what is under the pointer.
public bool SnapToSurfaceWhether a drop or a drag lands on the surface under the pointer.
public bool SnapRotationWhether a rotate rounds to AngleStep.
public bool SnapScaleWhether a scale rounds to ScaleStep.
public WorkPlane? PlaneThe plane whose step this follows, or for a step of its own.
public float GridStepHow far apart the grid lines are, in world units.
public float AngleStepHow far one rotation step is, in degrees.
public float ScaleStepHow far one scale step is, as a factor.
public float VertexRadiusHow near an element has to be to be snapped to, in render pixels.
public bool SnapsToGeometryWhether any element needing geometry under the pointer is on.
Methods (8)
public bool Has(SnapElements element)Whether an element is on.
public bool Is(SnapModifiers modifier)Whether a modifier is on.
public void Toggle(SnapElements element, bool on)Turns an element on or off.
public void Toggle(SnapModifiers modifier, bool on)Turns a modifier on or off.
public float Position(float value)Rounds a distance to the grid, if position snapping is on.
public Vector3 Position(Vector3 value)Rounds an offset to the grid, component by component.
public float Rotation(float radians)Rounds an angle in radians to the angle step, if rotation snapping is on.
public float Scale(float factor)Rounds a scale factor, if scale snapping is on.
Used by (16)
- EditorApplicationVixen.Editor.App
- GizmoTestsVixen.Editor.SceneView.Tests
- ISceneProbeVixen.Editor.SceneView
- PrecisionTestsVixen.Editor.SceneView.Tests
- ScenePlacementVixen.Editor.SceneView
- SceneProbeVixen.Editor.SceneView
- SceneTestsVixen.Editor.SceneView.Tests
- SceneViewportVixen.Editor.SceneView
- SnapCommandTestsVixen.Editor.App.Tests
- SnapContextTestsVixen.Editor.SceneView.Tests
- SnapTestsVixen.Editor.SceneView.Tests
- SplineEditVixen.Editor.SceneView
- SplineEditTestsVixen.Editor.SceneView.Tests
- TransformGizmoVixen.Editor.SceneView
- WorkPlaneCommandTestsVixen.Editor.App.Tests
- WorkPlaneTestsVixen.Editor.SceneView.Tests