Snapping Branch
@andybak snapping discussion continued...
the root of unity's scene graph we call "global space"so that sounds wrong. we don't want to work in the unity scene space - we want the canvas space
"canvas space" = the user's artwork. Typically there's just a single Canvas whose pose is the same as the Scene pose (it's a direct child of the scene, with identity localTransform). But when you have a selection or groups, those are additional Canvas instances
But when you have a selection or groups, those are additional Canvas instancesMy initial thought is that we can ignore this as we're working ON a selection and not IN a selection but I might be wrong.
var outXf_CS = outXf_GS.TransformBy(App.Scene.Pose.inverse);
outXf_CS.translation = QuantizePosition(outXf_CS.translation);
outXf_GS = outXf_CS.TransformBy(App.Scene.Pose);var outXf_CS = outXf_GS.TransformBy(App.Scene.Pose.inverse); public static Vector3 SnapToGrid(Vector3 position)
{
float gridSize = SelectionManager.m_Instance.SnappingGridSize;
Vector3 localCanvasPos = App.ActiveCanvas.transform.worldToLocalMatrix.MultiplyPoint3x4(position);
float round(float val) { return Mathf.Round(val / gridSize) * gridSize; }
Vector3 roundedCanvasPos = new Vector3(
round(localCanvasPos.x),
round(localCanvasPos.y),
round(localCanvasPos.z)
);
return App.ActiveCanvas.transform.localToWorldMatrix.MultiplyPoint3x4(roundedCanvasPos);
} if (SelectionManager.m_Instance.CurrentSnapGridIndex != 0)
{
outXf_GS.translation = SnapToGrid(outXf_GS.translation);
}