protected override void CalculateDragValues()
        {
            float dragAlongAxis0 = _planeDragSession.DragDelta.Dot(_workData.Axis0);
            float dragAlongAxis1 = _planeDragSession.DragDelta.Dot(_workData.Axis1);

            if (CanSnap())
            {
                _relativeDragOffset = Vector3.zero;

                _accumSnapDrag0 += dragAlongAxis0;
                _accumSnapDrag1 += dragAlongAxis1;

                if (SnapMath.CanExtractSnap(_workData.SnapStep0, _accumSnapDrag0))
                {
                    float snapAmount = SnapMath.ExtractSnap(_workData.SnapStep0, ref _accumSnapDrag0);
                    _relativeDragOffset += _workData.Axis0 * snapAmount;
                }

                if (SnapMath.CanExtractSnap(_workData.SnapStep1, _accumSnapDrag1))
                {
                    float snapAmount = SnapMath.ExtractSnap(_workData.SnapStep1, ref _accumSnapDrag1);
                    _relativeDragOffset += _workData.Axis1 * snapAmount;
                }
            }
            else
            {
                _accumSnapDrag0 = 0.0f;
                _accumSnapDrag1 = 0.0f;

                _relativeDragOffset = _planeDragSession.DragDelta * Sensitivity;
            }

            _totalDragOffset += _relativeDragOffset;
        }
Пример #2
0
        protected override void CalculateDragValues()
        {
            if (CanSnap())
            {
                _relativeDragScale = Vector3.one;
                _accumSnapDrag    += _planeDragSession.DragDelta.Dot(_scaleDragAxis);

                if (SnapMath.CanExtractSnap(_workData.SnapStep, _accumSnapDrag))
                {
                    float snapAmount = SnapMath.ExtractSnap(_workData.SnapStep, ref _accumSnapDrag);

                    float oldScale = _scale;
                    _scale            += snapAmount;
                    _relativeScale     = _scale / oldScale;
                    _totalScale        = _scale / 1.0f;
                    _relativeDragScale = Vector3Ex.FromValue(_relativeScale);
                }
            }
            else
            {
                _accumSnapDrag = 0;

                float oldScale = _scale;
                _scale            += _planeDragSession.DragDelta.Dot(_scaleDragAxis) * Sensitivity;
                _relativeScale     = _scale / oldScale;
                _totalScale        = _scale / 1.0f;
                _relativeDragScale = Vector3Ex.FromValue(_relativeScale);
            }

            _totalDragScale = Vector3Ex.FromValue(_totalScale);
        }
        protected override void CalculateDragValues()
        {
            Vector3 planeDragPoint        = _planeDragSession.DragPoint;
            Vector3 offsetFromScaleOrigin = (planeDragPoint - _workData.DragOrigin);

            float dragAlongAxis0 = offsetFromScaleOrigin.Dot(_planeAxis0);
            float dragAlongAxis1 = offsetFromScaleOrigin.Dot(_planeAxis1);

            if (CanSnap())
            {
                _relativeDragScale = Vector3.one;
                float accumDrag = (dragAlongAxis0 + dragAlongAxis1);
                if (SnapMath.CanExtractSnap(_workData.SnapStep, accumDrag))
                {
                    float oldScaledSize = _scaledSize;
                    _scaledSize        = _workData.BaseSize + SnapMath.ExtractSnap(_workData.SnapStep, accumDrag);
                    _relativeScale     = _scaledSize / oldScaledSize;
                    _totalScale        = _scaledSize / _workData.BaseSize;
                    _relativeDragScale = Vector3Ex.FromValue(_relativeScale);
                }
            }
            else
            {
                float oldScaledSize = _scaledSize;
                _scaledSize        = _workData.BaseSize + (dragAlongAxis0 + dragAlongAxis1) * Sensitivity;
                _relativeScale     = _scaledSize / oldScaledSize;
                _totalScale        = _scaledSize / _workData.BaseSize;
                _relativeDragScale = Vector3Ex.FromValue(_relativeScale);
            }

            _totalDragScale = Vector3Ex.FromValue(_totalScale);
        }
        protected override void CalculateDragValues()
        {
            float dragAlongAxis = _planeDragSession.DragDelta.Dot(_workData.Axis);

            if (CanSnap())
            {
                _relativeDragScale = Vector3.one;

                _accumSnapDrag += dragAlongAxis;
                if (SnapMath.CanExtractSnap(_workData.SnapStep, _accumSnapDrag))
                {
                    float snapAmount = SnapMath.ExtractSnap(_workData.SnapStep, ref _accumSnapDrag);

                    float oldScale = _scale;
                    _scale        += snapAmount;
                    _totalScale    = _scale / _workData.EntityScale;
                    _relativeScale = _scale / oldScale;
                    _relativeDragScale[_workData.AxisIndex] = _relativeScale;
                }
            }
            else
            {
                _accumSnapDrag = 0.0f;

                float oldScale = _scale;
                _scale        += dragAlongAxis * Sensitivity;
                _totalScale    = _scale / _workData.EntityScale;
                _relativeScale = _scale / oldScale;
                _relativeDragScale[_workData.AxisIndex] = _relativeScale;
            }

            _totalDragScale[_workData.AxisIndex] = _totalScale;
        }
Пример #5
0
        protected override void CalculateDragValues()
        {
            float dragAlongAxis0, dragAlongAxis1;
            float snapStep0, snapStep1;
            float entScale0, entScale1;

            dragAlongAxis0 = _planeDragSession.DragDelta.Dot(_scaleDragAxis);
            dragAlongAxis1 = dragAlongAxis0;

            snapStep0 = snapStep1 = _workData.SnapStep;
            entScale0 = entScale1 = 1.0f;

            if (CanSnap())
            {
                _relativeDragScale = Vector3.one;

                _accumSnapDrag0 += dragAlongAxis0;
                if (SnapMath.CanExtractSnap(snapStep0, _accumSnapDrag0))
                {
                    float oldScale = _scale0;
                    _scale0        += SnapMath.ExtractSnap(snapStep0, ref _accumSnapDrag0);
                    _totalScale0    = _scale0 / entScale0;
                    _relativeScale0 = _scale0 / oldScale;
                    _relativeDragScale[_workData.AxisIndex0] = _relativeScale0;
                }

                _accumSnapDrag1 += dragAlongAxis1;
                if (SnapMath.CanExtractSnap(snapStep1, _accumSnapDrag1))
                {
                    float oldScale = _scale1;
                    _scale1        += SnapMath.ExtractSnap(snapStep1, ref _accumSnapDrag1);
                    _totalScale1    = _scale1 / entScale1;
                    _relativeScale1 = _scale1 / oldScale;
                    _relativeDragScale[_workData.AxisIndex1] = _relativeScale1;
                }
            }
            else
            {
                _accumSnapDrag0 = 0.0f;
                _accumSnapDrag1 = 0.0f;

                float oldScale = _scale0;
                _scale0        += dragAlongAxis0 * Sensitivity;
                _totalScale0    = _scale0 / entScale0;
                _relativeScale0 = _scale0 / oldScale;
                _relativeDragScale[_workData.AxisIndex0] = _relativeScale0;

                oldScale        = _scale1;
                _scale1        += dragAlongAxis1 * Sensitivity;
                _totalScale1    = _scale1 / entScale1;
                _relativeScale1 = _scale1 / oldScale;
                _relativeDragScale[_workData.AxisIndex1] = _relativeScale1;
            }

            _totalDragScale[_workData.AxisIndex0] = _totalScale0;
            _totalDragScale[_workData.AxisIndex1] = _totalScale1;
        }
Пример #6
0
        protected override void CalculateDragValues()
        {
            float dragAlongAxis = _planeDragSession.DragDelta.Dot(_workData.Axis);

            if (CanSnap())
            {
                _relativeDragOffset = Vector3.zero;

                _accumSnapDrag += dragAlongAxis;
                if (SnapMath.CanExtractSnap(_workData.SnapStep, _accumSnapDrag))
                {
                    float snapAmount = SnapMath.ExtractSnap(_workData.SnapStep, ref _accumSnapDrag);
                    _relativeDragOffset = _workData.Axis * snapAmount;
                }
            }
            else
            {
                _accumSnapDrag      = 0.0f;
                _relativeDragOffset = _workData.Axis * dragAlongAxis * Sensitivity;
            }

            _totalDragOffset += _relativeDragOffset;
        }
        protected override void CalculateDragValues()
        {
            IInputDevice inputDevice      = RTInputDevice.Get.Device;
            Vector2      inputDeviceDelta = inputDevice.GetFrameDelta();

            _relativeRotation0 = Vector2.Dot(inputDeviceDelta, _workData.ScreenAxis0) * Sensitivity;
            _relativeRotation1 = Vector2.Dot(inputDeviceDelta, _workData.ScreenAxis1) * Sensitivity;

            if (_relativeRotation0 == 0.0f && _relativeRotation1 == 0.0f)
            {
                _relativeDragRotation = Quaternion.identity;
                return;
            }

            if (CanSnap())
            {
                _accumSnapDrag0 += _relativeRotation0;
                _accumSnapDrag0 %= 360.0f;

                _accumSnapDrag1 += _relativeRotation1;
                _accumSnapDrag1 %= 360.0f;

                if (_workData.SnapMode == GizmoSnapMode.Absolute && _adjustRotationForAbsSnap)
                {
                    NumSnapSteps numSnapSteps = SnapMath.CalculateNumSnapSteps(_workData.SnapStep0, _totalRotation0);
                    float        oldRotation  = _totalRotation0;
                    if (numSnapSteps.AbsFracSteps < 0.5f)
                    {
                        _totalRotation0 = numSnapSteps.AbsIntNumSteps * _workData.SnapStep0 * Mathf.Sign(_totalRotation0);
                    }
                    else
                    {
                        _totalRotation0 = (numSnapSteps.AbsIntNumSteps + 1) * _workData.SnapStep0 * Mathf.Sign(_totalRotation0);
                    }

                    _accumSnapDrag0    = 0.0f;
                    _relativeRotation0 = _totalRotation0 - oldRotation;

                    numSnapSteps = SnapMath.CalculateNumSnapSteps(_workData.SnapStep1, _totalRotation1);
                    oldRotation  = _totalRotation1;
                    if (numSnapSteps.AbsFracSteps < 0.5f)
                    {
                        _totalRotation1 = numSnapSteps.AbsIntNumSteps * _workData.SnapStep1 * Mathf.Sign(_totalRotation1);
                    }
                    else
                    {
                        _totalRotation1 = (numSnapSteps.AbsIntNumSteps + 1) * _workData.SnapStep1 * Mathf.Sign(_totalRotation1);
                    }

                    _accumSnapDrag1       = 0.0f;
                    _relativeRotation1    = _totalRotation1 - oldRotation;
                    _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation1, _workData.Axis1) * Quaternion.AngleAxis(_relativeRotation0, _workData.Axis0);

                    _adjustRotationForAbsSnap = false;
                }
                else
                {
                    _relativeDragRotation = Quaternion.identity;

                    if (SnapMath.CanExtractSnap(_workData.SnapStep0, _accumSnapDrag0))
                    {
                        _relativeRotation0 = SnapMath.ExtractSnap(_workData.SnapStep0, ref _accumSnapDrag0);
                        _totalRotation0   += _relativeRotation0;
                        _totalRotation0   %= 360.0f;

                        _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation0, _workData.Axis0);
                    }

                    if (SnapMath.CanExtractSnap(_workData.SnapStep1, _accumSnapDrag1))
                    {
                        _relativeRotation1 = SnapMath.ExtractSnap(_workData.SnapStep1, ref _accumSnapDrag1);
                        _totalRotation1   += _relativeRotation1;
                        _totalRotation1   %= 360.0f;

                        _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation1, _workData.Axis1) * _relativeDragRotation;
                    }
                }
            }
            else
            {
                _adjustRotationForAbsSnap = true;
                _accumSnapDrag0           = _accumSnapDrag1 = 0.0f;

                _totalRotation0 += _relativeRotation0;
                _totalRotation1 += _relativeRotation1;

                _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation1, _workData.Axis1) * Quaternion.AngleAxis(_relativeRotation0, _workData.Axis0);
            }

            _totalDragRotation = _relativeDragRotation * _totalDragRotation;
        }
Пример #8
0
        protected override void CalculateDragValues()
        {
            IInputDevice inputDevice = RTInputDevice.Get.Device;

            _relativeRotation = Vector2.Dot(_screenDragCircleTangent, inputDevice.GetFrameDelta()) * Sensitivity;

            if (_relativeRotation == 0.0f)
            {
                _relativeDragRotation = Quaternion.identity;
                return;
            }

            if (CanSnap())
            {
                _accumSnapDrag += _relativeRotation;
                _accumSnapDrag %= 360.0f;

                if (_workData.SnapMode == GizmoSnapMode.Absolute && _adjustRotationForAbsSnap)
                {
                    NumSnapSteps numSnapSteps = SnapMath.CalculateNumSnapSteps(_workData.SnapStep, _totalRotation);

                    float oldRotation = _totalRotation;
                    if (numSnapSteps.AbsFracSteps < 0.5f)
                    {
                        _totalRotation = numSnapSteps.AbsIntNumSteps * _workData.SnapStep * Mathf.Sign(_totalRotation);
                    }
                    else
                    {
                        _totalRotation = (numSnapSteps.AbsIntNumSteps + 1) * _workData.SnapStep * Mathf.Sign(_totalRotation);
                    }

                    _relativeRotation = _totalRotation - oldRotation;
                    _accumSnapDrag    = 0.0f;

                    _relativeDragRotation     = Quaternion.AngleAxis(_relativeRotation, _workData.Axis);
                    _adjustRotationForAbsSnap = false;
                }
                else
                if (SnapMath.CanExtractSnap(_workData.SnapStep, _accumSnapDrag))
                {
                    _relativeRotation = SnapMath.ExtractSnap(_workData.SnapStep, ref _accumSnapDrag);
                    _totalRotation   += _relativeRotation;
                    _totalRotation   %= 360.0f;

                    _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation, _workData.Axis);
                }
                else
                {
                    _relativeDragRotation = Quaternion.identity;
                }
            }
            else
            {
                _accumSnapDrag            = 0.0f;
                _adjustRotationForAbsSnap = true;

                _totalRotation += _relativeRotation;
                _totalRotation %= 360.0f;

                _relativeDragRotation = Quaternion.AngleAxis(_relativeRotation, _workData.Axis);
            }

            _totalDragRotation = Quaternion.AngleAxis(_totalRotation, _workData.Axis);
        }
Пример #9
0
        protected override void CalculateDragValues()
        {
            float dragAlongAxis0, dragAlongAxis1;
            float snapStep0, snapStep1;
            float baseSize0, baseSize1;

            if (_workData.ScaleMode == GizmoDblAxisScaleMode.Independent)
            {
                dragAlongAxis0 = _planeDragSession.DragDelta.Dot(_workData.Axis0);
                dragAlongAxis1 = _planeDragSession.DragDelta.Dot(_workData.Axis1);

                snapStep0 = _workData.IndSnapStep0;
                snapStep1 = _workData.IndSnapStep1;
                baseSize0 = _workData.IndBaseSize0;
                baseSize1 = _workData.IndBaseSize1;
            }
            else
            {
                dragAlongAxis0 = _planeDragSession.DragDelta.Dot(_workData.PropAxis);
                dragAlongAxis1 = dragAlongAxis0;

                snapStep0 = snapStep1 = _workData.PropSnapStep;
                baseSize0 = baseSize1 = _workData.PropBaseSize;
            }

            if (CanSnap())
            {
                _relativeDragScale = Vector3.one;

                _accumSnapDrag0 += dragAlongAxis0;
                if (SnapMath.CanExtractSnap(snapStep0, _accumSnapDrag0))
                {
                    float oldScaledSize = _scaledSize0;
                    _scaledSize0   += SnapMath.ExtractSnap(snapStep0, ref _accumSnapDrag0);
                    _totalScale0    = _scaledSize0 / baseSize0;
                    _relativeScale0 = _scaledSize0 / oldScaledSize;
                    _relativeDragScale[_workData.AxisIndex0] = _relativeScale0;
                }

                _accumSnapDrag1 += dragAlongAxis1;
                if (SnapMath.CanExtractSnap(snapStep1, _accumSnapDrag1))
                {
                    float oldScaledSize = _scaledSize1;
                    _scaledSize1   += SnapMath.ExtractSnap(snapStep1, ref _accumSnapDrag1);
                    _totalScale1    = _scaledSize1 / baseSize1;
                    _relativeScale1 = _scaledSize1 / oldScaledSize;
                    _relativeDragScale[_workData.AxisIndex1] = _relativeScale1;
                }
            }
            else
            {
                _accumSnapDrag0 = 0.0f;
                _accumSnapDrag1 = 0.0f;

                float oldScaledSize = _scaledSize0;
                _scaledSize0   += dragAlongAxis0 * Sensitivity;
                _totalScale0    = _scaledSize0 / baseSize0;
                _relativeScale0 = _scaledSize0 / oldScaledSize;
                _relativeDragScale[_workData.AxisIndex0] = _relativeScale0;

                oldScaledSize   = _scaledSize1;
                _scaledSize1   += dragAlongAxis1 * Sensitivity;
                _totalScale1    = _scaledSize1 / baseSize1;
                _relativeScale1 = _scaledSize1 / oldScaledSize;
                _relativeDragScale[_workData.AxisIndex1] = _relativeScale1;
            }

            _totalDragScale[_workData.AxisIndex0] = _totalScale0;
            _totalDragScale[_workData.AxisIndex1] = _totalScale1;
        }