protected override void CalculateDragValues() { Camera focusCamera = RTFocusCamera.Get.TargetCamera; _relativeDragOffset = Vector3.zero; if (_destinationObjects.Count != 0 && _settings.CanSnapToObjectVerts) { Vector3 worldDestPos; if (GetWorldPointClosestToInputDevice(focusCamera, _destinationObjects, out worldDestPos)) { _relativeDragOffset = worldDestPos - _snapPivot; } } else if (_settings.CanSnapToGrid) { Ray ray = RTInputDevice.Get.Device.GetRay(focusCamera); XZGridRayHit gridHit = RTScene.Get.RaycastSceneGridIfVisible(ray); if (gridHit != null) { XZGridCell gridCell = RTSceneGrid.Get.CellFromWorldPoint(gridHit.HitPoint); List <Vector3> centersAndCorners = gridCell.GetCenterAndCorners(); int closestPtIndex = Vector3Ex.GetPointClosestToPoint(centersAndCorners, gridHit.HitPoint); if (closestPtIndex >= 0) { _relativeDragOffset = centersAndCorners[closestPtIndex] - _snapPivot; } } } _snapPivot += _relativeDragOffset; _totalDragOffset += _relativeDragOffset; }